Skip to content

Commit

Permalink
fixes #112 - handle check out not on any branch in _is_git_dirty
Browse files Browse the repository at this point in the history
  • Loading branch information
jantman committed Dec 17, 2015
1 parent 3e0b90f commit 4574376
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
13 changes: 13 additions & 0 deletions awslimitchecker/tests/test_versioncheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,19 @@ def test_is_git_dirty_false_detatched(self):
call(['git', 'status', '-u'], stderr=DEVNULL)
]

def test_is_git_dirty_false_no_branch(self):
cls = AGPLVersionChecker()
with patch('%s._check_output' % self.mpb) as mock_check_out:
mock_check_out.return_value = dedent("""
Not currently on any branch.
nothing to commit, working directory clean
""")
res = cls._is_git_dirty()
assert res is False
assert mock_check_out.mock_calls == [
call(['git', 'status', '-u'], stderr=DEVNULL)
]

def test_is_git_dirty_true_ahead(self):
cls = AGPLVersionChecker()
with patch('%s._check_output' % self.mpb) as mock_check_out:
Expand Down
3 changes: 2 additions & 1 deletion awslimitchecker/versioncheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ def _is_git_dirty(self):
'-u'
], stderr=DEVNULL).strip()
if (('Your branch is up-to-date with' not in status and
'HEAD detached at' not in status) or
'HEAD detached at' not in status and
'Not currently on any branch' not in status) or
'nothing to commit' not in status):
logger.debug("Git repository dirty based on status: %s", status)
return True
Expand Down

0 comments on commit 4574376

Please sign in to comment.