You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by no...@apache.org on 2020/12/29 12:56:49 UTC

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

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

not-in-ldap 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)