summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Mewett <tom.mewett@codethink.co.uk>2020-01-08 13:11:48 +0000
committerTom Mewett <tom.mewett@codethink.co.uk>2020-01-14 10:54:17 +0000
commit410a27995dee2141eeed48a12e604574e3e56e15 (patch)
tree663aa43c22cb366518fd2371a9c6e1383f4e2ba7
parentc171026e988fa79383843c4880e9733a2acb1cf4 (diff)
downloadbuildstream-410a27995dee2141eeed48a12e604574e3e56e15.tar.gz
_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.
-rw-r--r--src/buildstream/_gitsourcebase.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/buildstream/_gitsourcebase.py b/src/buildstream/_gitsourcebase.py
index 7d1858a0a..271a08efc 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})