summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2013-04-27 22:26:36 +0200
committerGuido Günther <agx@sigxcpu.org>2013-04-27 22:35:48 +0200
commit059af98c610a8c4924e42d1b62429a89f3dc5dcb (patch)
tree6063c5a33bfd172516906c3dffdfc1ddb602e1cb
parent71e9e244caabfca463e7898ff684a9861bb5a582 (diff)
GitRepository.has_feature: capture stderr
to avoid spurious output on the console and add the error message to the exception intead.
-rw-r--r--gbp/git/repository.py7
-rw-r--r--tests/test_GitRepository.py2
2 files changed, 6 insertions, 3 deletions
diff --git a/gbp/git/repository.py b/gbp/git/repository.py
index 78d8701..8f87854 100644
--- a/gbp/git/repository.py
+++ b/gbp/git/repository.py
@@ -188,9 +188,12 @@ class GitRepository(object):
@rtype: C{bool}
"""
args = GitArgs(command, '-m')
- help, foo, ret = self._git_inout('help', args.args)
+ help, stderr, ret = self._git_inout('help',
+ args.args,
+ capture_stderr=True)
if ret:
- raise GitRepositoryError("Invalid git command: %s" % command)
+ raise GitRepositoryError("Invalid git command '%s': %s"
+ % (command, stderr[:-1]))
# Parse git command man page
section_re = re.compile(r'^(?P<section>[A-Z].*)')
diff --git a/tests/test_GitRepository.py b/tests/test_GitRepository.py
index 7365dd8..bec0836 100644
--- a/tests/test_GitRepository.py
+++ b/tests/test_GitRepository.py
@@ -828,7 +828,7 @@ def test_cmd_has_feature():
>>> repo._cmd_has_feature("foobarcmd", "foobaroption")
Traceback (most recent call last):
...
- GitRepositoryError: Invalid git command: foobarcmd
+ GitRepositoryError: Invalid git command 'foobarcmd': No manual entry for gitfoobarcmd
>>> repo._cmd_has_feature("show", "standard-notes")
True
>>> repo._cmd_has_feature("show", "no-standard-notes")