diff options
author | Daniel Gollub <dgollub@brocade.com> | 2015-03-17 08:12:53 +0100 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2015-04-25 09:19:56 +0200 |
commit | aa8548d526397a3c4353b7212f3f848ab1f1e283 (patch) | |
tree | 1a5d0ee3741167bbf471b1fb04ba1797aa01a935 /gbp/git | |
parent | 4a53c0f5c5819fb26cd02d746f08d6d4f4ba18f0 (diff) |
Guess upstream-tag based on merge-base
In some unfortunate cases you might have something like this:
$ git tag
v1.0
vyatta/1.0-0something1
... where later tag is closer to describe current HEAD.
With upstream-tag set to v%(version)s find_tag() is going to propose
something based on vyatta/1.0-0something1 which is not expected.
The problem is that find_tag() returns tags, which match the
upstream-tag format, but which are not on the upstream-branch at all.
To fix this find_tag()/git-describe should not be used to determine
the closest upstream-tag.
Closes: gh#7
Diffstat (limited to 'gbp/git')
-rw-r--r-- | gbp/git/repository.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/gbp/git/repository.py b/gbp/git/repository.py index 689430f0..3b208bf4 100644 --- a/gbp/git/repository.py +++ b/gbp/git/repository.py @@ -713,6 +713,21 @@ class GitRepository(object): """ return self.describe(commit, pattern, abbrev=0) + def find_branch_tag(self, commit, branch, pattern=None): + """ + Find the closest tag on a certain branch to a given commit + + @param commit: the commit to describe + @type commit: C{str} + @type branch: C{str} + @param pattern: only look for tags matching I{pattern} + @type pattern: C{str} + @return: the found tag + @rtype: C{str} + """ + base_commit = self.get_merge_base(commit, branch) + return self.describe(base_commit, pattern, abbrev=0) + def get_tags(self, pattern=None): """ List tags |