-
Notifications
You must be signed in to change notification settings - Fork 149
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
[question] Unexpected stdout
when running git check-ignore
#178
Comments
@kittaakos I haven't had a chance to look into this, but a first step might be to check if |
I have checked both describe('check-ignore', () => {
it('should list the ignored files from the root', async () => {
const testRepoPath = await initialize('check-ignore')
const aFile = Path.join(testRepoPath, 'a.txt')
Fs.writeFileSync(aFile, 'foo')
expect(Fs.readFileSync(aFile, { encoding: 'utf8' })).to.be.equal('foo')
const bFile = Path.join(testRepoPath, 'a.txt')
Fs.writeFileSync(bFile, 'bar')
expect(Fs.readFileSync(bFile, { encoding: 'utf8' })).to.be.equal('bar')
const gitignore = Path.join(testRepoPath, '.gitignore')
Fs.writeFileSync(gitignore, 'a.txt')
expect(Fs.readFileSync(gitignore, { encoding: 'utf8' })).to.be.equal('a.txt')
const aResult = await GitProcess.exec(['check-ignore', 'a.txt'], testRepoPath)
verify(aResult, r => {
expect(r.exitCode).to.be.equal(0)
expect(r.stdout.trim()).to.be.equal('a.txt')
})
const bResult = await GitProcess.exec(['check-ignore', 'b.txt'], testRepoPath)
verify(bResult, r => {
expect(r.exitCode).to.be.equal(1)
expect(r.stdout.trim()).to.be.equal('')
})
})
}) And the result is the same from a terminal:
Update: |
@kittaakos I think this is because NodeJS might not be expanding This question delves into a couple of the alternatives to this, but I don't think they'll work directly for this use case. |
I found the exact same thread and tried out to call
|
If I change the // ...
const command = [gitLocation, ...args].join(' ')
let cp: ChildProcess
if ('win32' === process.platform) {
cp = spawn('cmd.exe', ['/s', '/c', '"' + command + '"'], spawnOptions)
} else {
cp = spawn('/bin/sh', ['-c', command], spawnOptions)
}
// ...
cp.on('error', ...)
cp.on('exit', ...)
cp.stdout.on('data', ...)
cp.stderr.on('data', ...) (Just wanted to try it out.) Also, all tests pass except the Although I also found this and this threads on the By the way, alternatively, I could use the |
@shiftkey, are there any plans adjusting the implementation. I could take care of the PR if you do not have time. Also, I could understand if you do not want to switch from |
I'm swamped, but would be happy to review the changes if you've found a way to resolve it. |
Great, I will take care of it. Thanks! |
Signed-off-by: Akos Kitta <[email protected]>
Closes desktop#178. Signed-off-by: Akos Kitta <[email protected]>
I tried to run
git check-ignore
fromdugite
. Unfortunately, I got different results when I ran it from a terminal, and when I executed the command from code. Perhaps, I misunderstood something, or I must be blind. Could you please tell me what is wrong with my test case? Thank you!From the code:
From a terminal:
The text was updated successfully, but these errors were encountered: