#!/bin/sh # Back up uncommitted work in this tree before anything runs a `clean` checkout. # # WHY THIS EXISTS # master.cfg's checkout step is: # steps.Git(repourl=REPO, mode='full', method='clean') # and buildbot runs the build INSIDE this working tree # (buildbot-worker puts its builddir under $BUILDWORKER_WORKDIR = /worker). # So every build silently reverts any uncommitted change here. This bit us # once: a finished PieMenu edit was discarded by a build and had to be # reconstructed by hand. # # Run this before `./gradlew`, before pushing, and before any build you did # not initiate yourself. It is cheap and it is the only copy. set -e TREE=${1:-/ROM/worker/kukuri-build/build} STAMP=$(date +%Y%m%d-%H%M%S) OUT=/ROM/worker-cache/uncommitted-$STAMP.patch cd "$TREE" if git diff --quiet && git diff --cached --quiet; then echo "clean - nothing to back up" exit 0 fi mkdir -p "$(dirname "$OUT")" { echo "# uncommitted work captured $(date -Iseconds) from $TREE" echo "# HEAD was $(git rev-parse --short HEAD) $(git log -1 --format=%s)" echo git diff echo echo "# --- staged ---" git diff --cached } > "$OUT" STAGED=$(git diff --cached --name-only | tr '\n' ' ') UNSTAGED=$(git diff --name-only | tr '\n' ' ') echo "backed up to $OUT" echo " staged: ${STAGED:-none}" echo " unstaged: ${UNSTAGED:-none}" wc -l "$OUT"