Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCM issue #75862

Closed
mbelsky opened this issue Jun 20, 2019 · 4 comments
Closed

SCM issue #75862

mbelsky opened this issue Jun 20, 2019 · 4 comments
Assignees
Labels
git GIT issues info-needed Issue requires more information from poster

Comments

@mbelsky
Copy link
Contributor

mbelsky commented Jun 20, 2019

Hey,

There is an interesting issue with SCM on Windows 10: commit from shell and SCM has different result. When I commit through shell it fails on running tests and it doesn't when I commit through SCM. On MacOS I can't reproduce this issue.

Steps to Reproduce:

  1. Clone https://github.com/mbelsky/js-problems and open in VS Code.
  2. Run npm i to setup jest and husky.
  3. Open problems/001-sum.js file and replace undefined with 1.
  4. Run git commit -am 'test' in shell and it fails as expected
  5. Open SCM, stage changes for 001-sum.js, write message and commit, but this won't fail and will be added to the repo.
  • Version: 1.35.1 (user setup)
  • Commit: c7d83e5
  • Date: 2019-06-12T14:30:02.622Z
  • Electron: 3.1.8
  • Chrome: 66.0.3359.181
  • Node.js: 10.2.0
  • V8: 6.6.346.32
  • OS: Windows_NT x64 10.0.17134

Does this issue occur when all extensions are disabled?: Yes

@vscodebot vscodebot bot added the git GIT issues label Jun 20, 2019
@joaomoreno
Copy link
Member

This seems like a user configuration issue, not related to VS Code. First, you should figure out what is the correct behavior in that case: should the linting fail or not? Then, you should try to figure out why it misbehaves in each case. VS Code simply spawns git.exe to commit, so you can inspect processes and see whether the linting task is called at all.

@joaomoreno joaomoreno added the info-needed Issue requires more information from poster label Jun 24, 2019
@mbelsky
Copy link
Contributor Author

mbelsky commented Jun 24, 2019

Thanks for response. The correct behavior in this case: the linting should fail, because 001-sum.js doesn't pass tests.

I found an interesting thing. While I manually run git commit through cmd.exe or bash.exe lint-staged generate tasks with [ 'C:\\Users\\publi\\js\\js-problems\\problems\\001-sum.js' ] fileList. And when I commit through SCM it generate tasks with [ 'c:\\Users\\publi\\js\\js-problems\\problems\\001-sum.js' ] fileList (lower-case 'c') and jest cannot find this file.

SCM commit output
husky > pre-commit (node v10.16.0)
2019-06-24T18:36:02.859Z lint-staged:bin Running `lint-staged@8.1.5`
2019-06-24T18:36:03.424Z lint-staged:find-bin Loaded package.json using `process.cwd()`
2019-06-24T18:36:03.652Z lint-staged Loading config using `cosmiconfig`
2019-06-24T18:36:03.660Z lint-staged Successfully loaded config from `c:\Users\publi\js\js-problems\package.json`:
{ '*.js': [ 'jest --bail --findRelatedTests' ] }
2019-06-24T18:36:03.660Z lint-staged:cfg Normalizing config
2019-06-24T18:36:03.662Z lint-staged:cfg Validating config
Running lint-staged with the following config:
{
  linters: {
    '*.js': [
      'jest --bail --findRelatedTests'
    ]
  },
  concurrent: true,
  chunkSize: 9007199254740991,
  globOptions: {
    matchBase: true,
    dot: true
  },
  ignore: [],
  subTaskConcurrency: 1,
  renderer: 'verbose',
  relative: false
}
2019-06-24T18:36:03.669Z lint-staged:run Running all linter scripts
2019-06-24T18:36:03.670Z lint-staged:run Resolved git directory to be `c:\Users\publi\js\js-problems`
2019-06-24T18:36:03.712Z lint-staged:run Loaded list of staged files in git:
[ 'problems/001-sum.js' ]
2019-06-24T18:36:03.712Z lint-staged:gen-tasks Generating linter tasks
2019-06-24T18:36:03.712Z lint-staged:cfg Normalizing config
2019-06-24T18:36:03.720Z lint-staged:gen-tasks Generated task: 
{ pattern: '*.js',
  commands: [ 'jest --bail --findRelatedTests' ],
  fileList:
   [ 'c:\\Users\\publi\\js\\js-problems\\problems\\001-sum.js' ] }
Stashing changes... [started]
Stashing changes... [skipped]
→ No partially staged files found...
Running linters... [started]
Running tasks for *.js [started]
2019-06-24T18:36:03.767Z lint-staged:make-cmd-tasks Creating listr tasks for commands [ 'jest --bail --findRelatedTests' ]
2019-06-24T18:36:03.768Z lint-staged:find-bin Resolving binary for command `jest --bail --findRelatedTests`
2019-06-24T18:36:03.774Z lint-staged:find-bin Binary for `jest --bail --findRelatedTests` resolved to `c:\Users\publi\js\js-problems\node_modules\.bin\jest.CMD`
2019-06-24T18:36:03.774Z lint-staged:task OS: win32; Creating linter task with 1 chunked file paths
jest --bail --findRelatedTests [started]
2019-06-24T18:36:03.778Z lint-staged:task bin: c:\Users\publi\js\js-problems\node_modules\.bin\jest.CMD
2019-06-24T18:36:03.778Z lint-staged:task args: [ '--bail',
  '--findRelatedTests',
  'c:\\Users\\publi\\js\\js-problems\\problems\\001-sum.js' ]
2019-06-24T18:36:03.778Z lint-staged:task opts: { reject: false }
jest --bail --findRelatedTests [completed]
Running tasks for *.js [completed]
Running linters... [completed]
2019-06-24T18:36:04.854Z lint-staged linters were executed successfully!
bash.exe output
husky > pre-commit (node v10.16.0)
  lint-staged:bin Running `lint-staged@8.1.5` +0ms
  lint-staged:find-bin Loaded package.json using `process.cwd()` +0ms
  lint-staged Loading config using `cosmiconfig` +0ms
  lint-staged Successfully loaded config from `C:\Users\publi\js\js-problems\package.json`:
  lint-staged { '*.js': [ 'jest --bail --findRelatedTests' ] } +6ms
  lint-staged:cfg Normalizing config +0ms
  lint-staged:cfg Validating config +2ms
Running lint-staged with the following config:
{
  linters: {
    '*.js': [
      'jest --bail --findRelatedTests'
    ]
  },
  concurrent: true,
  chunkSize: 9007199254740991,
  globOptions: {
    matchBase: true,
    dot: true
  },
  ignore: [],
  subTaskConcurrency: 1,
  renderer: 'verbose',
  relative: false
}
  lint-staged:run Running all linter scripts +0ms
  lint-staged:run Resolved git directory to be `C:\Users\publi\js\js-problems` +2ms
  lint-staged:run Loaded list of staged files in git:
  lint-staged:run [ 'problems/001-sum.js', 'package.json' ] +50ms
  lint-staged:gen-tasks Generating linter tasks +0ms
  lint-staged:cfg Normalizing config +59ms
  lint-staged:gen-tasks Generated task:
  lint-staged:gen-tasks { pattern: '*.js',
  lint-staged:gen-tasks   commands: [ 'jest --bail --findRelatedTests' ],
  lint-staged:gen-tasks   fileList:
  lint-staged:gen-tasks    [ 'C:\\Users\\publi\\js\\js-problems\\problems\\001-sum.js' ] } +9ms
Stashing changes... [started]
Stashing changes... [skipped]
→ No partially staged files found...
Running linters... [started]
Running tasks for *.js [started]
  lint-staged:make-cmd-tasks Creating listr tasks for commands [ 'jest --bail --findRelatedTests' ] +0ms
  lint-staged:find-bin Resolving binary for command `jest --bail --findRelatedTests` +378ms
  lint-staged:find-bin Binary for `jest --bail --findRelatedTests` resolved to `C:\Users\publi\js\js-problems\node_modules\.bin\jest.CMD` +7ms
  lint-staged:task OS: win32; Creating linter task with 1 chunked file paths +0ms
jest --bail --findRelatedTests [started]
  lint-staged:task bin: C:\Users\publi\js\js-problems\node_modules\.bin\jest.CMD +4ms
  lint-staged:task args: [ '--bail',
  lint-staged:task   '--findRelatedTests',
  lint-staged:task   'C:\\Users\\publi\\js\\js-problems\\problems\\001-sum.js' ] +1ms
  lint-staged:task opts: { reject: false } +0ms
jest --bail --findRelatedTests [failed]
→
Running tasks for *.js [failed]
→
Running linters... [failed]

× jest --bail --findRelatedTests found some errors. Please fix them and try committing again.

FAIL problems/tests/001.js
× Тестирование задачи "001-sum" (4009ms)

● Тестирование задачи "001-sum"

expect(received).toBe(expected) // Object.is equality

Expected: 3
Received: 1

 5 |     expect(sum(0)).toBe(1);
 6 |     expect(sum(1)).toBe(1);

7 | expect(sum(2)).toBe(3);
| ^
8 | expect(sum(5)).toBe(15);
9 | });
10 |

at Object.toBe (problems/__tests__/001.js:7:20)

Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 total
Snapshots: 0 total
Time: 5s, estimated 6s
Ran all test suites related to files matching /C:\Users\publi\js\js-problems\problems\001-sum.js/i.
husky > pre-commit hook failed (add --no-verify to bypass)

Could disk letter case depend on SCM or I should go to lint-staged repo with this issue?

@joaomoreno
Copy link
Member

joaomoreno commented Jun 25, 2019

Let's try to figure out why jest can't find that file. In Windows paths are case insensitive.

@mbelsky
Copy link
Contributor Author

mbelsky commented Jun 25, 2019

It looks like Jest has case sensitivity issues.

Thank you for your assistance with this matter.

@mbelsky mbelsky closed this as completed Jun 25, 2019
@vscodebot vscodebot bot locked and limited conversation to collaborators Aug 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
git GIT issues info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

2 participants