Show running Gateway commit and available updates
This commit is contained in:
1 parent
32b240469c
commit
36b2057991
12 files changed
+188
-21
No files matched your search
@@ -0,0 +1,30 @@
|
||||
set -euo pipefail
|
||||
umask 077
|
||||
export GIT_TERMINAL_PROMPT=0 GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_NOSYSTEM=1
|
||||
|
||||
running=$1
|
||||
[[ $running =~ ^[0-9a-f]{40}$ ]]
|
||||
ref="refs/heads/$SEIUGW_UPDATE_BRANCH"
|
||||
remote="$SEIUGW_UPDATE_REMOTE"
|
||||
tip=$(timeout --kill-after=1s 8s git ls-remote --exit-code --refs -- "$remote" "$ref")
|
||||
tip=${tip%%$'\t'*}
|
||||
[[ $tip =~ ^[0-9a-f]{40}$ ]]
|
||||
if [[ $tip == "$running" ]]; then
|
||||
printf 'current %s\n' "$tip"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Check ancestry in a temporary repository. The update worker owns the live checkout.
|
||||
probe=$(mktemp -d)
|
||||
trap 'rm -rf -- "$probe"' EXIT
|
||||
git init --quiet --bare "$probe"
|
||||
timeout --kill-after=1s 18s git -C "$probe" fetch --quiet --no-tags -- "$remote" "$ref"
|
||||
tip=$(git -C "$probe" rev-parse FETCH_HEAD)
|
||||
if [[ $tip == "$running" ]]; then
|
||||
printf 'current %s\n' "$tip"
|
||||
elif git -C "$probe" cat-file -e "$running^{commit}" 2>/dev/null &&
|
||||
git -C "$probe" merge-base --is-ancestor "$running" "$tip"; then
|
||||
printf 'available %s\n' "$tip"
|
||||
else
|
||||
printf 'incompatible %s\n' "$tip"
|
||||
fi
|
||||
Reference in new issue
Block a user