Files

29 lines
904 B
Bash
Executable File

#!/bin/sh
# Timer target: rebuild the garden only when the vault or repo changed.
# Successor to the Quartz update_quartz_docker.sh change-detection loop.
set -eu
REPO=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
VAULT="${VAULT:-/home/nox/docker/obsidian/vaults/weeslahw_coppermind}"
STATE="$REPO/.build_state"
cd "$REPO"
# a dirty tree can make pull fail; still rebuild whatever is checked out
git pull -q || echo "git pull failed (dirty tree?) — building local state"
# signature covers committed HEAD, any uncommitted repo edits, and vault mtimes
sig=$({
git rev-parse HEAD
git status --porcelain=v1
git diff
find "$VAULT" -name .obsidian -prune -o -type f -printf '%T@ %p\n' | sort
} | sha256sum | cut -d' ' -f1)
if [ -f "$STATE" ] && [ "$(cat "$STATE")" = "$sig" ]; then
exit 0
fi
sh "$REPO/deploy/build.sh"
printf %s "$sig" >"$STATE"
echo "garden rebuilt $(date -Is)"