diff --git a/src/status.coffee b/src/status.coffee index fa4d856..0e35eaf 100644 --- a/src/status.coffee +++ b/src/status.coffee @@ -11,7 +11,10 @@ module.exports = S = (repo, callback) -> BEGIN_STAGED = "# Changes to be committed:" -BEGIN_UNSTAGED = "# Changed but not updated:" +BEGIN_UNSTAGED = [ + "# Changed but not updated:" + "# Changes not staged for commit:" +] BEGIN_UNTRACKED = "# Untracked files:" FILE = /^#\s+([^\s]+)[:]\s+(.+)$/ TYPES = @@ -31,7 +34,7 @@ S.Status = class Status if line == BEGIN_STAGED state = "staged" @clean = false - else if line == BEGIN_UNSTAGED + else if ~BEGIN_UNSTAGED.indexOf(line) state = "unstaged" @clean = false else if line == BEGIN_UNTRACKED diff --git a/test/status.test.coffee b/test/status.test.coffee index e9e66f7..b1c5b6d 100644 --- a/test/status.test.coffee +++ b/test/status.test.coffee @@ -26,6 +26,17 @@ GIT_STATUS_CLEAN = """ # On branch master # nothing to commit (working directory clean) """ +GIT_STATUS_NOT_CLEAN = """ + # 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: lib/index.js + # modified: npm-shrinkwrap.json + # modified: package.json + # + """ describe "Status", -> describe "()", -> @@ -37,7 +48,13 @@ describe "Status", -> it "is clean", -> status.clean.should.be.true - + describe "when there are changes", -> + repo = fixtures.status + status = new Status.Status repo + status.parse GIT_STATUS_NOT_CLEAN + it "is not clean", -> + status.clean.should.be.false + describe "when there are changes", -> repo = fixtures.status status = new Status.Status repo