summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2018-02-25 16:38:25 +0100
committerJavier Jardón <jjardon@gnome.org>2018-09-15 17:11:14 +0100
commit90c5875d1fd73bbc462e1d4472318e7373e84502 (patch)
tree4e9803c6d5d58307addb8032cc0017f2259694be
parentdec8dfbc32f013fd8edcad875cffabcc8a905286 (diff)
downloadbuildstream-jjardon/juerg/git-track-tags.tar.gz
git.py: Support tracking annotated tags in a branchjjardon/juerg/git-track-tags
-rw-r--r--buildstream/plugins/sources/git.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/buildstream/plugins/sources/git.py b/buildstream/plugins/sources/git.py
index 947ba0856..38bb6f6d3 100644
--- a/buildstream/plugins/sources/git.py
+++ b/buildstream/plugins/sources/git.py
@@ -186,7 +186,14 @@ class GitMirror(SourceFetcher):
raise SourceError("{}: expected ref '{}' was not found in git repository: '{}'"
.format(self.source, self.ref, self.url))
- def latest_commit(self, tracking):
+ def latest_commit(self, tracking, *, track_tags):
+ if track_tags:
+ _, output = self.source.check_output(
+ [self.source.host_git, 'describe', '--abbrev=0', tracking],
+ fail="Unable to find annotated tag for specified branch name '{}'".format(tracking),
+ cwd=self.mirror)
+ tracking = output.rstrip('\n')
+
_, output = self.source.check_output(
[self.source.host_git, 'rev-parse', tracking],
fail="Unable to find commit for specified branch name '{}'".format(tracking),
@@ -304,11 +311,12 @@ class GitSource(Source):
def configure(self, node):
ref = self.node_get_member(node, str, 'ref', None)
- config_keys = ['url', 'track', 'ref', 'submodules', 'checkout-submodules']
+ config_keys = ['url', 'track', 'track-tags', 'ref', 'submodules', 'checkout-submodules']
self.node_validate(node, config_keys + Source.COMMON_CONFIG_KEYS)
self.original_url = self.node_get_member(node, str, 'url')
self.mirror = GitMirror(self, '', self.original_url, ref, primary=True)
+ self.track_tags = self.node_get_member(node, bool, 'track-tags', False)
self.tracking = self.node_get_member(node, str, 'track', None)
# At this point we now know if the source has a ref and/or a track.
@@ -396,7 +404,7 @@ class GitSource(Source):
self.mirror._fetch()
# Update self.mirror.ref and node.ref from the self.tracking branch
- ret = self.mirror.latest_commit(self.tracking)
+ ret = self.mirror.latest_commit(self.tracking, track_tags=self.track_tags)
return ret