GitRepository.describe: add 'tags' and 'extra-match' options
authorLingchaox Xin <lingchaox.xin@intel.com>
Thu, 20 Jun 2013 01:34:01 +0000 (09:34 +0800)
committerGuido Günther <agx@sigxcpu.org>
Wed, 4 Sep 2013 20:32:55 +0000 (22:32 +0200)
Signed-off-by: Lingchaox Xin <lingchaox.xin@intel.com>
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
gbp/git/repository.py
tests/test_GitRepository.py

index 79492a1ebc3af5fd16dc047a046ff9a74091e47d..9c55dfd8b82654603b820ad76ec20db9abc517a9 100644 (file)
@@ -625,7 +625,7 @@ class GitRepository(object):
         return [ False, True ][len(out)]
 
     def describe(self, commitish, pattern=None, longfmt=False, always=False,
-                 abbrev=None):
+                 abbrev=None, tags=False, exact_match=False):
         """
         Describe commit, relative to the latest tag reachable from it.
 
@@ -639,6 +639,11 @@ class GitRepository(object):
         @type always: C{bool}
         @param abbrev: abbreviate sha1 to given length instead of the default
         @type abbrev: None or C{long}
+        @param tags: enable matching a lightweight (non-annotated) tag
+        @type tags: C{bool}
+        @param exact_match: only output exact matches (a tag directly
+        references the supplied commit)
+        @type exact_match: C{bool}
         @return: tag name plus/or the abbreviated sha1
         @rtype: C{str}
         """
@@ -652,6 +657,8 @@ class GitRepository(object):
         elif abbrev is not None:
             args.add('--abbrev=%s' % abbrev)
         args.add_true(always, '--always')
+        args.add_true(tags, '--tags')
+        args.add_true(exact_match, '--exact-match')
         args.add(commitish)
 
         tag, err, ret = self._git_inout('describe', args.args,
index 8dafc2a23adc4cf9ff0adf827a12f8e6d5d275d0..24bdae2696b92f76e5f0b0ff9e686042c924dab9 100644 (file)
@@ -266,6 +266,12 @@ def test_describe():
     >>> repo.describe('HEAD', pattern='foo*', always=True, abbrev=16) == sha[:16]
     True
     >>> tag = repo.describe('HEAD', longfmt=True, abbrev=16) == 'tag2-0-g%s' % sha[:16]
+    >>> repo.delete_tag('tag2')
+    >>> repo.describe('HEAD', tags=True)
+    'tag'
+    >>> repo.describe('HEAD', tags=True, exact_match=True)
+    'tag'
+    >>> repo.create_tag('tag2', msg='foo')
     """
 
 def test_find_tag():