File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ # Fail when SOURCE_REF does not match the current commit (tuple bookkeeping).
3+ set -euo pipefail
4+
5+ ROOT=" $( cd " $( dirname " $0 " ) /.." && pwd) "
6+ cd " $ROOT "
7+
8+ if [[ ! -f SOURCE_REF ]]; then
9+ echo " SKIP: SOURCE_REF not present yet (add when bumping the ecosystem tuple)."
10+ exit 0
11+ fi
12+
13+ HEAD=" $( git rev-parse HEAD) "
14+ REF=" $( tr -d ' [:space:]' < SOURCE_REF) "
15+ if ! echo " $REF " | grep -qE ' ^[0-9a-f]{40}$' ; then
16+ echo " Invalid SOURCE_REF: must be a 40-character lowercase git SHA" >&2
17+ exit 1
18+ fi
19+
20+ if [[ " $HEAD " == " $REF " ]]; then
21+ echo " PASS: SOURCE_REF matches HEAD ($HEAD )."
22+ exit 0
23+ fi
24+
25+ if git merge-base --is-ancestor " $REF " " $HEAD " 2> /dev/null; then
26+ echo " FAIL: HEAD ($HEAD ) is ahead of SOURCE_REF ($REF )" >&2
27+ echo " Bump SOURCE_REF to HEAD and update spec pins/matrix for the tuple." >&2
28+ exit 1
29+ fi
30+
31+ echo " FAIL: SOURCE_REF ($REF ) is not an ancestor of HEAD ($HEAD )" >&2
32+ exit 1
You can’t perform that action at this time.
0 commit comments