launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #26761
[Merge] ~twom/launchpad:oci-fix-tagging-tag-names into launchpad:master
Tom Wardill has proposed merging ~twom/launchpad:oci-fix-tagging-tag-names into launchpad:master.
Commit message:
Account for tag names in the correct branch format
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~twom/launchpad/+git/launchpad/+merge/400377
If you manage to select a tag from the branch picker, then we shouldn't attempt to upload the manifest to an invalid location.
LP:1921865
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~twom/launchpad:oci-fix-tagging-tag-names into launchpad:master.
diff --git a/lib/lp/oci/model/ociregistryclient.py b/lib/lp/oci/model/ociregistryclient.py
index 34a8c1e..8c27040 100644
--- a/lib/lp/oci/model/ociregistryclient.py
+++ b/lib/lp/oci/model/ociregistryclient.py
@@ -257,7 +257,11 @@ class OCIRegistryClient:
"""
tags = []
if recipe.is_valid_branch_format:
- tags.append("{}_{}".format(recipe.git_ref.name, "edge"))
+ ref_name = recipe.git_ref.name
+ # lp:1921865, account for tags in the correct format
+ if ref_name.startswith("refs/tags/"):
+ ref_name = ref_name[len("refs/tags/"):]
+ tags.append("{}_{}".format(ref_name, "edge"))
else:
tags.append("edge")
return tags
diff --git a/lib/lp/oci/tests/test_ociregistryclient.py b/lib/lp/oci/tests/test_ociregistryclient.py
index 10f3af8..e30a470 100644
--- a/lib/lp/oci/tests/test_ociregistryclient.py
+++ b/lib/lp/oci/tests/test_ociregistryclient.py
@@ -418,6 +418,13 @@ class TestOCIRegistryClient(OCIConfigHelperMixin, SpyProxyCallsMixin,
self.assertThat(result, MatchesListwise(
[Equals("v1.0-20.04_edge")]))
+ def test_calculateTags_valid_tag(self):
+ [git_ref] = self.factory.makeGitRefs(paths=["refs/tags/v1.0-20.04"])
+ self.build.recipe.git_ref = git_ref
+ result = self.client._calculateTags(self.build.recipe)
+ self.assertThat(result, MatchesListwise(
+ [Equals("v1.0-20.04_edge")]))
+
def test_build_registry_manifest(self):
self._makeFiles()
preloaded_data = self.client._preloadFiles(