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

[buildstream] 03/13: _gitsourcebase.py: Strip git-describe tag info from cache key

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

root pushed a commit to branch tmewett/merge-git-tag
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 410a27995dee2141eeed48a12e604574e3e56e15
Author: Tom Mewett <to...@codethink.co.uk>
AuthorDate: Wed Jan 8 13:11:48 2020 +0000

    _gitsourcebase.py: Strip git-describe tag info from cache key
    
    The beginning parts of git-describe labels are completely arbitrary.
    They can be changed either manually or by a track (e.g. if a tag is
    moved, added or deleted) even if the referenced commit is the same.
    Hence, only the commit ID part of the label should factor into the cache
    key.
    
    This commit, of course, breaks cache keys for artifacts built with the
    'git' source with git-describe refs.
---
 src/buildstream/_gitsourcebase.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/buildstream/_gitsourcebase.py b/src/buildstream/_gitsourcebase.py
index 7d1858a..271a08e 100644
--- a/src/buildstream/_gitsourcebase.py
+++ b/src/buildstream/_gitsourcebase.py
@@ -530,10 +530,16 @@ class _GitSourceBase(Source):
         self.host_git = utils.get_host_tool("git")
 
     def get_unique_key(self):
+        ref = self.mirror.ref
+        if ref is not None:
+            # If the ref contains "-g" (is in git-describe format),
+            # only choose the part after, which is the commit ID
+            ref = ref.split("-g")[-1]
+
         # Here we want to encode the local name of the repository and
         # the ref, if the user changes the alias to fetch the same sources
         # from another location, it should not affect the cache key.
-        key = [self.original_url, self.mirror.ref]
+        key = [self.original_url, ref]
         if self.mirror.tags:
             tags = {tag: (commit, annotated) for tag, commit, annotated in self.mirror.tags}
             key.append({"tags": tags})