#!/usr/bin/env bash # Records this run's HEAD as the watermark restore-mtimes.sh reads back on # this cache directory's NEXT run. # # Usage: record-watermark.sh # # Run only after the build has succeeded: a failed run leaves the watermark at # the last GREEN build, which is the conservative direction (over-invalidates, # never under-invalidates). See restore-mtimes.sh's header for what the # watermark is for. # # Written with write-then-rename so this directory's next run can never # observe a truncated, half-written watermark. set -euo pipefail DIR="${1:?usage: record-watermark.sh }" NAME="${2:?}" mkdir -p "$DIR" git rev-parse HEAD > "$DIR/${NAME}.tmp" mv -f "$DIR/${NAME}.tmp" "$DIR/${NAME}" echo "watermark: $(cat "$DIR/${NAME}") recorded in ${DIR}/${NAME}"