aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/test_GitRepository.py
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2012-09-27 12:33:10 +0300
committerGuido Günther <agx@sigxcpu.org>2012-11-07 20:56:03 +0100
commitf4d2e21f475a7f6f9039f7b7ce223b9179f9cfbe (patch)
tree3d1ccbb59c489e2f2000dfd4a8b7a96b89b2a1ba /tests/test_GitRepository.py
parent323bdcfa2f7bfa2f2402c22c4c90ca060243daaf (diff)
GitRepository: implement _cmd_has_feature() method
This method is intended for checking if the local git (client) command supports a certain feature. The "feature" is considered to be a command line option. E.g. does "merge" command have the "edit" feature translates to does git-merge support the '--edit' command line option. To figure this out, _cmd_has_feature() parses through the "OPTIONS" section of the man page of the git command. Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Diffstat (limited to 'tests/test_GitRepository.py')
-rw-r--r--tests/test_GitRepository.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/test_GitRepository.py b/tests/test_GitRepository.py
index aa20e755..f1b50131 100644
--- a/tests/test_GitRepository.py
+++ b/tests/test_GitRepository.py
@@ -753,6 +753,31 @@ def test_get_merge_base():
GitRepositoryError: Failed to get common ancestor: fatal: Not a valid object name doesnotexist
"""
+def test_cmd_has_feature():
+ r"""
+ Methods tested:
+ - L{gbp.git.GitRepository._cmd_has_feature}
+
+ >>> import gbp.git
+ >>> repo = gbp.git.GitRepository(repo_dir)
+ >>> repo._cmd_has_feature("commit", "a")
+ True
+ >>> repo._cmd_has_feature("commit", "reuse-message")
+ True
+ >>> repo._cmd_has_feature("merge", "n")
+ True
+ >>> repo._cmd_has_feature("merge", "stat")
+ True
+ >>> repo._cmd_has_feature("format-patch", "cc")
+ True
+ >>> repo._cmd_has_feature("merge", "foobaroption")
+ False
+ >>> repo._cmd_has_feature("foobarcmd", "foobaroption")
+ Traceback (most recent call last):
+ ...
+ GitRepositoryError: Invalid git command: foobarcmd
+ """
+
def test_teardown():
"""
Perform the teardown