diff --git a/openfut-blaze-host/build.rs b/openfut-blaze-host/build.rs index f6eea38..0a465d0 100644 --- a/openfut-blaze-host/build.rs +++ b/openfut-blaze-host/build.rs @@ -66,4 +66,13 @@ fn main() { println!("cargo:rerun-if-changed={p}"); } } + // Committing updates refs/heads/, NOT the HEAD file, so watching + // HEAD alone leaves the stamp one commit behind. Observed: the banner read + // a84a72e immediately after committing 2337431. + if let Some(rf) = git(&["symbolic-ref", "-q", "HEAD"]) { + let path = format!("../.git/{rf}"); + if std::path::Path::new(&path).exists() { + println!("cargo:rerun-if-changed={path}"); + } + } } diff --git a/openfut-blaze-host/sidecar.sh b/openfut-blaze-host/sidecar.sh index 2cc00a9..1c47e96 100755 --- a/openfut-blaze-host/sidecar.sh +++ b/openfut-blaze-host/sidecar.sh @@ -116,6 +116,12 @@ cmd_start() { die "port $OPENFUT_BLAZE_HOST_PORT is already in use" fi + # The binary's stamp can lag the tree (cargo cannot know about every source + # change). Compare it with the tree's real HEAD at launch and say so, because + # an evidence artefact that names the wrong commit is worse than one that + # names none. + HEAD_NOW="$(git -C "$ROOT" rev-parse --short=7 HEAD 2>/dev/null || echo unknown)" + local tree tree="$(tree_state)" if [[ "$tree" == "DIRTY" ]]; then @@ -141,7 +147,15 @@ cmd_start() { fi if port_listening "$OPENFUT_BLAZE_HOST_PORT"; then echo "sidecar started: pid $pid, port $OPENFUT_BLAZE_HOST_PORT" - grep -m1 'openfut-blaze-host v' "$LOGFILE" 2>/dev/null | sed 's/^/ /' + local banner stamped + banner="$(grep -m1 'openfut-blaze-host v' "$LOGFILE" 2>/dev/null)" + echo " ${banner}" + stamped="$(sed -n 's/.*commit=\([0-9a-f]*\).*/\1/p' <<<"$banner")" + if [[ -n "$stamped" && "$stamped" != "unknown" && "$stamped" != "$HEAD_NOW" ]]; then + echo " !! STALE BUILD STAMP: binary says $stamped, HEAD is $HEAD_NOW" >&2 + echo " Rebuild before treating this run as evidence:" >&2 + echo " touch openfut-blaze-host/build.rs && cargo build -p openfut-blaze-host" >&2 + fi if grep -q 'WARNING: built from a modified working tree' "$LOGFILE" 2>/dev/null; then echo " !! DIRTY BUILD — results are not parity evidence" >&2 fi