You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by tv...@apache.org on 2021/02/04 07:51:32 UTC

[buildstream] 02/02: git.py: Support tracking annotated tags in a branch

This is an automated email from the ASF dual-hosted git repository.

tvb pushed a commit to branch jjardon/juerg/git-track-tags
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 90c5875d1fd73bbc462e1d4472318e7373e84502
Author: Jürg Billeter <j...@bitron.ch>
AuthorDate: Sun Feb 25 16:38:25 2018 +0100

    git.py: Support tracking annotated tags in a branch
---
 buildstream/plugins/sources/git.py | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/buildstream/plugins/sources/git.py b/buildstream/plugins/sources/git.py
index 947ba08..38bb6f6 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