node-coveralls icon indicating copy to clipboard operation
node-coveralls copied to clipboard

Rewrite local git detection using git command

Open dlackty opened this issue 8 years ago • 3 comments

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

dlackty avatar Jul 07 '16 13:07 dlackty

@nickmerwin after git gc it puts that file to .git/packed-refs

So I vote for this pull request

gugu avatar Dec 23 '16 08:12 gugu

The idea is good; it's better to rely on git itself than custom code.

My thoughts:

  1. we need to make sure everything works properly on all OS'es
  2. this might result in a slowness since we'll be spawning 2 git processes synchronously

XhmikosR avatar Nov 20 '19 14:11 XhmikosR

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.

jtwebman avatar Mar 06 '22 22:03 jtwebman