Release: peel signed component tags
Modular container CI / release-build (push) Has been cancelled

This commit is contained in:
faumaray committed 2026-07-30 02:52:23 +03:00
1 parent 0a5323aea7
commit 6331fce118
2 files changed
+53 -3

No files matched your search

+32 -3
View File
@@ -41,6 +41,28 @@ def command(*args: str, cwd: Path | None = None) -> str:
) from error
def remote_tag_commit(tag_output: str, tag: str) -> str | None:
if not tag_output:
return None
direct_ref = f"refs/tags/{tag}"
peeled_ref = f"{direct_ref}^{{}}"
revisions: dict[str, str] = {}
for line in tag_output.splitlines():
fields = line.split()
if len(fields) != 2:
raise ReleaseError(f"invalid ls-remote output for tag {tag}")
revision, reference = fields
if reference in (direct_ref, peeled_ref):
revisions[reference] = revision
if peeled_ref in revisions:
return revisions[peeled_ref]
if direct_ref in revisions:
return revisions[direct_ref]
raise ReleaseError(f"ls-remote did not return the requested tag {tag}")
def root_product_version(cmake_text: str) -> str:
matches = PROJECT_RE.findall(cmake_text)
if len(matches) != 1:
@@ -214,9 +236,16 @@ def resolve_component(
)
)
expected_tag = f"v{version}"
tag_line = command("git", "ls-remote", "--tags", url, expected_tag)
if tag_line:
tag_revision = tag_line.split()[0]
tag_output = command(
"git",
"ls-remote",
"--tags",
url,
f"refs/tags/{expected_tag}",
f"refs/tags/{expected_tag}^{{}}",
)
tag_revision = remote_tag_commit(tag_output, expected_tag)
if tag_revision is not None:
if tag_revision != revision:
raise ReleaseError(
f"{component_id} tag {expected_tag} points at "
+21
View File
@@ -15,6 +15,27 @@ SPEC.loader.exec_module(MODULE)
class PrepareReleaseTests(unittest.TestCase):
def test_remote_tag_commit_accepts_lightweight_tag(self) -> None:
revision = "a" * 40
self.assertEqual(
MODULE.remote_tag_commit(
f"{revision}\trefs/tags/v2.0.0", "v2.0.0"
),
revision,
)
def test_remote_tag_commit_peels_signed_annotated_tag(self) -> None:
tag_object = "a" * 40
revision = "b" * 40
self.assertEqual(
MODULE.remote_tag_commit(
f"{tag_object}\trefs/tags/v2.0.0\n"
f"{revision}\trefs/tags/v2.0.0^{{}}",
"v2.0.0",
),
revision,
)
def test_root_version_is_the_only_product_version(self) -> None:
self.assertEqual(
MODULE.root_product_version(