|
1 | 1 | #!/usr/bin/env bash |
2 | 2 | set -euo pipefail |
3 | 3 |
|
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" |
5 | 7 |
|
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 |
11 | 10 |
|
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 |
14 | 19 | exit 1 |
15 | 20 | fi |
16 | 21 |
|
17 | | -echo "Tracked commit: $TRACKED_COMMIT" |
18 | | -echo "Latest commit: $LATEST_COMMIT" |
| 22 | +echo "Tracked blob: $TRACKED_BLOB" |
| 23 | +echo "Latest blob: $LATEST_BLOB" |
19 | 24 |
|
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" |
22 | 27 | exit 1 |
23 | 28 | fi |
24 | 29 |
|
|
0 commit comments