node-coveralls
node-coveralls copied to clipboard
Rewrite local git detection using git command
We recently encountered a error when we tried to run node-coveralls on a Git tagged revision without a branch. I know it sounds a bit of weird to do that, but it's the default behavior of Phabricator's Diffusion code review tool.
When debugging this issue, I found that we can get required information just using git command, so I rewrote the function and it works on our CircleCI setup.
This is error log:
fs.js:549
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: ENOENT: no such file or directory, open '/home/ubuntu/blog/.git/refs/heads/master'
at Error (native)
at Object.fs.openSync (fs.js:549:18)
at Object.fs.readFileSync (fs.js:397:15)
at detectLocalGit (/home/ubuntu/blog/node_modules/coveralls/lib/detectLocalGit.js:26:19)
at getBaseOptions (/home/ubuntu/blog/node_modules/coveralls/lib/getOptions.js:92:43)
at Object.getOptions (/home/ubuntu/blog/node_modules/coveralls/lib/getOptions.js:149:3)
at handleInput (/home/ubuntu/blog/node_modules/coveralls/lib/handleInput.js:7:8)
at Socket.<anonymous> (/home/ubuntu/blog/node_modules/coveralls/bin/coveralls.js:16:5)
at emitNone (events.js:72:20)
at Socket.emit (events.js:166:7)
cat ./coverage/lcov.info | ./node_modules/.bin/coveralls returned exit code 1
@nickmerwin after git gc
it puts that file to .git/packed-refs
So I vote for this pull request
The idea is good; it's better to rely on git itself than custom code.
My thoughts:
- we need to make sure everything works properly on all OS'es
- this might result in a slowness since we'll be spawning 2 git processes synchronously
Since this library doesn't seem to be supported anymore I fix a bunch of things on a fork if you want to check it out and are still pulling the library into your packages: https://github.com/jtwebman/coveralls-next I am very open to changes like these.