Skip to content

Commit 25f9c07

Browse files
committed
fix: prefer peeled commit hashes for annotated tags
1 parent 111689e commit 25f9c07

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

nix/ext/scripts/update_versions_json.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,32 @@ def run(cmd: List[str]) -> str:
2222
def get_tags(url: str) -> Dict[str, str]:
2323
output = run(["git", "ls-remote", "--tags", url])
2424
tags: Dict[str, str] = {}
25+
peeled_tags: Dict[str, str] = {}
26+
27+
# First pass: collect both normal and peeled entries
2528
for line in output.splitlines():
26-
if "^{}" not in line:
27-
parts = line.split("\t")
28-
if len(parts) == 2:
29-
commit_hash, ref = parts
30-
if ref.startswith("refs/tags/"):
29+
parts = line.split("\t")
30+
if len(parts) == 2:
31+
commit_hash, ref = parts
32+
if ref.startswith("refs/tags/"):
33+
if ref.endswith("^{}"):
34+
# This is a peeled tag (commit hash for annotated tag)
35+
tag = ref.removeprefix("refs/tags/").removesuffix("^{}")
36+
peeled_tags[tag] = commit_hash
37+
else:
38+
# Regular tag entry
3139
tag = ref.removeprefix("refs/tags/")
3240
try:
3341
parse_version(tag)
3442
except InvalidVersion:
3543
continue
3644
tags[tag] = commit_hash
45+
46+
# Second pass: prefer peeled commit hashes when available
47+
for tag, commit_hash in tags.items():
48+
if tag in peeled_tags:
49+
tags[tag] = peeled_tags[tag]
50+
3751
return tags
3852

3953

0 commit comments

Comments
 (0)