Skip to content

Commit 3658656

Browse files
romtsnclaude
andcommitted
fix: Use git protocol instead of Gitiles JSON API for retrace spec check
The Gitiles HTTP/JSON API frequently returns CAPTCHA/rate-limit pages on shared CI runner IPs, causing the check to fail with jq parse errors. Switch to shallow git fetch + blob hash comparison which uses the git protocol and avoids the CAPTCHA gate entirely. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 269214b commit 3658656

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

scripts/check-retrace-spec.sh

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
TRACKED_COMMIT="e212426be84283876b6bb832630c0de25a2a7bc5"
4+
# Blob hash of doc/retrace.md at the last known state.
5+
# To update: run this script's fetch logic manually and replace the hash.
6+
TRACKED_BLOB="ae22ff183a460d25fc0cecdd2d34f5b32ae216d9"
57

6-
# tail -n +2 to remove the magic anti-XSSI prefix from the Gitiles JSON response
7-
LATEST_COMMIT=$(curl -sf \
8-
'https://r8.googlesource.com/r8/+log/refs/heads/main/doc/retrace.md?format=JSON' \
9-
| tail -n +2 \
10-
| jq -r '.log[0].commit')
8+
TMPDIR=$(mktemp -d)
9+
trap 'rm -rf "$TMPDIR"' EXIT
1110

12-
if [ -z "$LATEST_COMMIT" ] || [ "$LATEST_COMMIT" = "null" ]; then
13-
echo "ERROR: Failed to fetch latest commit from Gitiles" >&2
11+
git init -q "$TMPDIR"
12+
git -C "$TMPDIR" remote add origin https://r8.googlesource.com/r8
13+
git -C "$TMPDIR" fetch --depth=1 origin refs/heads/main 2>/dev/null
14+
15+
LATEST_BLOB=$(git -C "$TMPDIR" ls-tree FETCH_HEAD -- doc/retrace.md | awk '{print $3}')
16+
17+
if [ -z "$LATEST_BLOB" ]; then
18+
echo "ERROR: Failed to read doc/retrace.md blob from r8 repo" >&2
1419
exit 1
1520
fi
1621

17-
echo "Tracked commit: $TRACKED_COMMIT"
18-
echo "Latest commit: $LATEST_COMMIT"
22+
echo "Tracked blob: $TRACKED_BLOB"
23+
echo "Latest blob: $LATEST_BLOB"
1924

20-
if [ "$LATEST_COMMIT" != "$TRACKED_COMMIT" ]; then
21-
echo "Spec has been updated! Latest: https://r8.googlesource.com/r8/+/${LATEST_COMMIT}/doc/retrace.md"
25+
if [ "$LATEST_BLOB" != "$TRACKED_BLOB" ]; then
26+
echo "Spec has been updated! View at: https://r8.googlesource.com/r8/+/refs/heads/main/doc/retrace.md"
2227
exit 1
2328
fi
2429

0 commit comments

Comments
 (0)