summaryrefslogtreecommitdiff
path: root/gbp/git/repository.py
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2013-10-16 10:20:18 +0200
committerGuido Günther <agx@sigxcpu.org>2013-10-16 10:29:46 +0200
commit3be29476f410022021ce04c2fdae98748ef03615 (patch)
tree39b1780dba4282b9b09fe7e4830c1ed093d75f73 /gbp/git/repository.py
parentba4f778de7dc23c372759984d620c93f70054bf9 (diff)
downloadgit-buildpackage-3be29476f410022021ce04c2fdae98748ef03615.tar.gz
git-buildpackage-3be29476f410022021ce04c2fdae98748ef03615.tar.bz2
git-buildpackage-3be29476f410022021ce04c2fdae98748ef03615.zip
Be more robust about git status output changes
by using --porcelain. Heavily based on a patch by rian m. carlson Closes: #726260
Diffstat (limited to 'gbp/git/repository.py')
-rw-r--r--gbp/git/repository.py39
1 files changed, 21 insertions, 18 deletions
diff --git a/gbp/git/repository.py b/gbp/git/repository.py
index 4a58eea3..cc723df4 100644
--- a/gbp/git/repository.py
+++ b/gbp/git/repository.py
@@ -761,6 +761,18 @@ class GitRepository(object):
args += [ commit, '--' ]
self._git_command("reset", args)
+ def _status(self, porcelain, ignore_untracked):
+ args = GitArgs()
+ args.add_true(ignore_untracked, '-uno')
+ args.add_true(porcelain, '--porcelain')
+
+ out, ret = self._git_getoutput('status',
+ args.args,
+ extra_env={'LC_ALL': 'C'})
+ if ret:
+ raise GitRepositoryError("Can't get repository status")
+ return out
+
def is_clean(self, ignore_untracked=False):
"""
Does the repository contain any uncommitted modifications?
@@ -775,24 +787,15 @@ class GitRepository(object):
if self.bare:
return (True, '')
- clean_msg = 'nothing to commit'
-
- args = GitArgs()
- args.add_true(ignore_untracked, '-uno')
-
- out, ret = self._git_getoutput('status',
- args.args,
- extra_env={'LC_ALL': 'C'})
- if ret:
- raise GbpError("Can't get repository status")
- ret = False
- for line in out:
- if line.startswith('#'):
- continue
- if line.startswith(clean_msg):
- ret = True
- break
- return (ret, "".join(out))
+ out = self._status(porcelain=True,
+ ignore_untracked=ignore_untracked)
+ if out:
+ # Get a more helpful error message.
+ out = self._status(porcelain=False,
+ ignore_untracked=ignore_untracked)
+ return (False, "".join(out))
+ else:
+ return (True, '')
def clean(self, directories=False, force=False, dry_run=False):
"""