#!/usr/bin/env bash # # Mirror the wilm branch onto gitea from a bundle carried over from the work PC. # # WHY THIS EXISTS # # wilm is maintained on the corporate GitHub (ge-aero) from the work PC. This # dev box is off the GE network and has no account there, so it can neither # fetch nor push that branch. The only way wilm reaches gitea is: # # 1. WORK PC: fetch-wilm-branch.cmd (read-only, writes the bundle) # 2. Carry shopdb-flask-wilm.bundle onto a drive this PC can read # 3. HERE: tools/mirror-wilm.sh # # Gitea is therefore the mirror of record for wilm and is ALWAYS lagging: it is # only as fresh as the last bundle somebody carried across. This script prints # the bundle's age for exactly that reason - a mirror that looks authoritative # and is a week old is worse than no mirror. # # It never pushes anything TO wilm. That branch belongs to the other site and # merging into it is a work-PC operation against GitHub. set -euo pipefail REPO=/home/camp/projects/shopdb-flask BUNDLE="${1:-/home/camp/pxe-images/github/shopdb-flask-wilm.bundle}" if [ ! -r "$BUNDLE" ]; then echo "No bundle at $BUNDLE" >&2 echo "Run fetch-wilm-branch.cmd on the work PC and copy it across." >&2 exit 1 fi if ! git bundle list-heads "$BUNDLE" | grep -q 'refs/remotes/origin/wilm'; then echo "$BUNDLE does not contain origin/wilm." >&2 echo "It is a bundle for something else - do not use it." >&2 exit 1 fi age_days=$(( ( $(date +%s) - $(stat -c %Y "$BUNDLE") ) / 86400 )) echo "Bundle: $BUNDLE" echo "Made: $(stat -c %y "$BUNDLE" | cut -d. -f1) (${age_days} day(s) ago)" if [ "$age_days" -ge 2 ]; then echo "WARNING: this bundle is ${age_days} days old. Whatever it pushes to" >&2 echo "gitea will look current and will not be." >&2 fi cd "$REPO" git fetch "$BUNDLE" 'refs/remotes/origin/wilm:refs/heads/wilm' --force echo "wilm is now $(git log --oneline -1 wilm)" # wilm sits on the PUBLICATION lineage (the scrubbed history that goes to # GitHub), which shares no ancestor with our internal main/wj/dev. That is why # the mirror is useful for reading and useless for merging: git will refuse to # merge unrelated histories, and it is right to. if ! git merge-base wilm main >/dev/null 2>&1; then echo echo "NOTE: wilm shares no ancestry with main/wj/dev in this repo - it is on" echo " the publication lineage. Compare it in the publication repo" echo " (/home/camp/projects/shopdb-flask-pub), not here." fi "$REPO/tools/git-push.sh" wilm