From 712928cd0ac218606eff44af1df3a168efad5358 Mon Sep 17 00:00:00 2001 From: sentientwaffle Date: Fri, 23 Mar 2012 08:58:50 -0600 Subject: [PATCH] fix Status#clean --- src/repo.coffee | 2 +- src/status.coffee | 4 +++- test/status.test.coffee | 13 +++++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/repo.coffee b/src/repo.coffee index b4101d4..7e82cd3 100644 --- a/src/repo.coffee +++ b/src/repo.coffee @@ -116,7 +116,7 @@ module.exports = class Repo # Public: Get the repository's status (`git status`). # - # callback - Receives `(err, callback)` + # callback - Receives `(err, status)` # status: (callback) -> return Status(this, callback) diff --git a/src/status.coffee b/src/status.coffee index 169a816..fa4d856 100644 --- a/src/status.coffee +++ b/src/status.coffee @@ -28,13 +28,15 @@ S.Status = class Status @clean = true state = null for line in text.split("\n") - @clean = false if line == BEGIN_STAGED state = "staged" + @clean = false else if line == BEGIN_UNSTAGED state = "unstaged" + @clean = false else if line == BEGIN_UNTRACKED state = "untracked" + @clean = false else if state && match = FILE.exec(line) file = match[2] data = switch state diff --git a/test/status.test.coffee b/test/status.test.coffee index d568e84..e9e66f7 100644 --- a/test/status.test.coffee +++ b/test/status.test.coffee @@ -22,9 +22,22 @@ GIT_STATUS = """ # # pickles.txt """ +GIT_STATUS_CLEAN = """ + # On branch master + # nothing to commit (working directory clean) + """ describe "Status", -> describe "()", -> + describe "when there are no changes", -> + repo = fixtures.status + status = new Status.Status repo + status.parse GIT_STATUS_CLEAN + + it "is clean", -> + status.clean.should.be.true + + describe "when there are changes", -> repo = fixtures.status status = new Status.Status repo