summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gbp/git/repository.py9
-rw-r--r--tests/test_GitRepository.py4
2 files changed, 12 insertions, 1 deletions
diff --git a/gbp/git/repository.py b/gbp/git/repository.py
index 4820e3f..9dd4748 100644
--- a/gbp/git/repository.py
+++ b/gbp/git/repository.py
@@ -183,12 +183,19 @@ class GitRepository(object):
# Parse git command man page
section_re = re.compile(r'^(?P<section>[A-Z].*)')
option_re = re.compile(r'--?(?P<name>[a-zA-Z\-]+).*')
+ optopt_re = re.compile(r'--\[(?P<prefix>[a-zA-Z\-]+)\]-?')
man_section = None
for line in help.splitlines():
if man_section == "OPTIONS" and line.startswith(' -'):
opts = line.split(',')
for opt in opts:
- match = option_re.match(opt.strip())
+ opt = opt.strip()
+ match = optopt_re.match(opt)
+ if match:
+ opts.append(re.sub(optopt_re, '--', opt))
+ prefix = match.group('prefix').strip('-')
+ opt = re.sub(optopt_re, '--%s-' % prefix, opt)
+ match = option_re.match(opt)
if match and match.group('name') == feature:
return True
# Check man section
diff --git a/tests/test_GitRepository.py b/tests/test_GitRepository.py
index 0e833b5..5029630 100644
--- a/tests/test_GitRepository.py
+++ b/tests/test_GitRepository.py
@@ -803,6 +803,10 @@ def test_cmd_has_feature():
Traceback (most recent call last):
...
GitRepositoryError: Invalid git command: foobarcmd
+ >>> repo._cmd_has_feature("show", "standard-notes")
+ True
+ >>> repo._cmd_has_feature("show", "no-standard-notes")
+ True
"""
def test_teardown():