Skip to content

Commit 2ddac96

Browse files
Alexandreclaude
andcommitted
Label main as "latest" in the version switcher
Also fix branch enumeration: %(refname:short) abbreviates refs/remotes/origin/HEAD to plain "origin", so the short-name filter missed it and a phantom "origin" version could reach git archive and fail the deploy. Match on the full refname instead. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 6eaadfd commit 2ddac96

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

‎.github/scripts/inject_version_switcher.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ def order(branches):
5858
return (["main"] if "main" in branches else []) + rest
5959

6060

61+
def label(branch):
62+
"""main holds the current release, so present it as "latest"."""
63+
return "latest" if branch == "main" else branch
64+
65+
6166
def widget(versions, current, site_root, page_path):
6267
options = []
6368
for name, directory in versions:
@@ -94,7 +99,7 @@ def main():
9499
print("Only %d version(s); skipping version switcher." % len(branches))
95100
return
96101

97-
versions = [(b, "" if b == "main" else b + "/") for b in order(branches)]
102+
versions = [(label(b), "" if b == "main" else b + "/") for b in order(branches)]
98103
# Longest directory first so "Autograph-2027/" wins over main's "".
99104
lookup = sorted(versions, key=lambda v: len(v[1]), reverse=True)
100105

‎.github/workflows/static.yml‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,12 @@ jobs:
4848
set -euo pipefail
4949
rm -rf _site && mkdir -p _site
5050
51-
git for-each-ref --format='%(refname:short)' refs/remotes/origin \
52-
| grep -v '^origin/HEAD$' \
53-
| sed 's|^origin/||' > branches.txt
51+
# Match on the full refname: %(refname:short) abbreviates
52+
# refs/remotes/origin/HEAD to plain "origin", which would slip
53+
# past a short-name filter and become a phantom branch.
54+
git for-each-ref --format='%(refname)' refs/remotes/origin \
55+
| grep -v '^refs/remotes/origin/HEAD$' \
56+
| sed 's|^refs/remotes/origin/||' > branches.txt
5457
5558
while read -r branch; do
5659
if [ "$branch" = "main" ]; then dest="_site"; else dest="_site/$branch"; fi

0 commit comments

Comments
 (0)