1
0
mirror of https://github.com/danog/gift.git synced 2025-01-22 05:51:18 +01:00

handle multiple "unstaged" messages

This commit is contained in:
sentientwaffle 2012-03-23 13:11:37 -06:00
parent a84da5dfda
commit 7f158c4813
2 changed files with 23 additions and 3 deletions

View File

@ -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

View File

@ -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,6 +48,12 @@ 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