#!/usr/bin/env bash # Copyright 2026 ResQ Software # SPDX-License-Identifier: Apache-2.0 # # Canonical ResQ post-merge shim — source: resq-software/dev. # Notifies when lock files change after a merge. set -euo pipefail [ -n "${GIT_HOOKS_SKIP:-}" ] && exit 0 # git passes 1 for a squash merge. `--squash` stages the result without # committing, so HEAD has not moved and a tree-to-tree diff sees nothing — # compare the working tree against ORIG_HEAD instead, which is where the merged # changes actually are. if [ "${1:-0}" = "1" ]; then CHANGED=$(git diff --name-only ORIG_HEAD 2>/dev/null || true) else CHANGED=$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD 2>/dev/null || true) fi # Matched by basename rather than anchored to the repository root: a monorepo # keeps lockfiles in nested workspaces (`libs/dotnet/flake.lock`, # `programs/Cargo.lock`), and a root-anchored pattern silently ignores them all. grep -qE "(^|/)Cargo\.lock$" <<<"$CHANGED" && echo "📦 Cargo.lock changed after merge — run: cargo build" # `\?` is a GNU BRE extension; BSD grep on macOS reads it as a literal `?`, so # the optional-`b` form needs ERE to match `bun.lock` on every developer's box. grep -qE "(^|/)bun\.lockb?$" <<<"$CHANGED" && echo "📦 bun.lock changed after merge — run: bun install" grep -qE "(^|/)uv\.lock$" <<<"$CHANGED" && echo "📦 uv.lock changed after merge — run: uv sync" grep -qE "(^|/)flake\.lock$" <<<"$CHANGED" && echo "📦 flake.lock changed after merge — exit and re-enter: nix develop" LOCAL_HOOK="$(git rev-parse --show-toplevel)/.git-hooks/local-post-merge" if [ -x "$LOCAL_HOOK" ]; then exec "$LOCAL_HOOK" "$@" fi exit 0