npm/npm — pull request #6991 by rlidwka (2014-12-22 23:14:18+00:00)
Title: npm version: handle checkGit errors

We seem to have a regression in https://github.com/npm/npm/commit/cb6ff8dace1b439851701d4784d2d719c22ca7a7. When npm checks whether git working directory is empty and errors out, this error gets ignored. Setup:

```
alex@y:/tmp$ mkdir test
alex@y:/tmp$ cd test
alex@y:/tmp/test$ git init
Initialized empty Git repository in /tmp/test/.git/
alex@y:/tmp/test$ echo '{"name":"foo","version":"1.2.3"}' > package.json
alex@y:/tmp/test$ git add package.json ; git commit -m init
[master (root-commit) 81af888] init
1 file changed, 1 insertion(+)
create mode 100644 package.json
alex@y:/tmp/test$ echo '{"name":"foox","version":"1.2.3"}' > package.json
alex@y:/tmp/test$ git status
On branch master
Changes not staged for commit:
(use "git add ..." to update what will be committed)
(use "git checkout -- ..." to discard changes in working directory)

modified: package.json

no changes added to commit (use "git add" and/or "git commit -a")
```

Expected (version unchanged, npm errors out):

```
alex@y:/tmp/test$ ../node_modules/.bin/npm -v
2.1.0
alex@y:/tmp/test$ ../node_modules/.bin/npm version patch
npm ERR! Linux 3.16.0-25-generic
npm ERR! argv "node" "/tmp/test/node_modules/.bin/npm" "version" "patch"
npm ERR! node v0.10.25
npm ERR! npm v2.1.0

npm ERR! Git working directory not clean.
npm ERR! M package.json
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!

npm ERR! Please include the following file with any support request:
npm ERR! /tmp/test/npm-debug.log
```

Actual (version bumped, no new git commits):

```
alex@y:/tmp/test$ ../node_modules/.bin/npm -v
2.1.14
alex@y:/tmp/test$ ../node_modules/.bin/npm version patch
v1.2.4
alex@y:/tmp/test$ git log
commit 81af88874960245e70fe709cfd03faabbf252a74
Author: Alex Kocharin
Date: Tue Dec 23 02:06:58 2014 +0300

init
```

Ping @othiym23.