diff options
author | Tom Mewett <tom.mewett@codethink.co.uk> | 2020-01-08 13:11:48 +0000 |
---|---|---|
committer | Tom Mewett <tom@collider.in> | 2020-01-24 14:32:59 +0000 |
commit | 2a49e0827d427850de26d5a4bb0d78d5bb1d1acc (patch) | |
tree | 9146d871c9e1e84b6563a427b4ad2e2b2a17c59c /src/buildstream | |
parent | b9f61a963e84d9594aecdfd5240b104c459ca72b (diff) | |
download | buildstream-2a49e0827d427850de26d5a4bb0d78d5bb1d1acc.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.
Diffstat (limited to 'src/buildstream')
-rw-r--r-- | src/buildstream/_gitsourcebase.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/buildstream/_gitsourcebase.py b/src/buildstream/_gitsourcebase.py index b9b6952e1..165bd7e2f 100644 --- a/src/buildstream/_gitsourcebase.py +++ b/src/buildstream/_gitsourcebase.py @@ -49,6 +49,10 @@ class _RefFormat(FastEnum): GIT_DESCRIBE = "git-describe" +def _strip_tag(rev): + return rev.split("-g")[-1] + + # This class represents a single Git repository. The Git source needs to account for # submodules, but we don't want to cache them all under the umbrella of the # superproject - so we use this class which caches them independently, according @@ -537,10 +541,15 @@ class _GitSourceBase(Source): self.host_git_version = None def get_unique_key(self): + ref = self.mirror.ref + if ref is not None: + # Strip any (arbitary) tag information, leaving just the commit ID + ref = _strip_tag(ref) + # 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}) |