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:30 UTC

[buildstream] branch jjardon/juerg/git-track-tags created (now 90c5875)

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

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


      at 90c5875  git.py: Support tracking annotated tags in a branch

This branch includes the following new commits:

     new dec8dfb  git.py: Make ref human readable
     new 90c5875  git.py: Support tracking annotated tags in a branch

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



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

Posted by tv...@apache.org.
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
 


[buildstream] 01/02: git.py: Make ref human readable

Posted by tv...@apache.org.
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 dec8dfbc32f013fd8edcad875cffabcc8a905286
Author: Jürg Billeter <j...@bitron.ch>
AuthorDate: Sun Feb 25 11:36:05 2018 +0100

    git.py: Make ref human readable
---
 buildstream/plugins/sources/git.py | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/buildstream/plugins/sources/git.py b/buildstream/plugins/sources/git.py
index 0658701..947ba08 100644
--- a/buildstream/plugins/sources/git.py
+++ b/buildstream/plugins/sources/git.py
@@ -191,7 +191,17 @@ class GitMirror(SourceFetcher):
             [self.source.host_git, 'rev-parse', tracking],
             fail="Unable to find commit for specified branch name '{}'".format(tracking),
             cwd=self.mirror)
-        return output.rstrip('\n')
+        ref = output.rstrip('\n')
+
+        # Prefix the ref with the closest annotated tag, if available,
+        # to make the ref human readable
+        exit_code, output = self.source.check_output(
+            [self.source.host_git, 'describe', '--abbrev=40', '--long', ref],
+            cwd=self.mirror)
+        if exit_code == 0:
+            ref = output.rstrip('\n')
+
+        return ref
 
     def stage(self, directory):
         fullpath = os.path.join(directory, self.path)