Files
MoFin/scripts/git-hook-post-merge.sh
hmo 9a359f49bd feat(deploy): automatic hardlink repair built into deployment pipeline
User insight: hardlink breakage only happens at deploy time (scp file
replacement / git checkout-merge), so detection must be welded INTO the
deploy pipeline, not left to daily audit.

Three automatic layers, no reliance on discipline:
1. systemd path watcher (profile-scripts-sync.path): watches
   deploy/profile-scripts/ directory, auto-fires sync_profile_scripts.sh
   on any change. Verified: fires within 4s of file replacement, logs to
   gateway/logs/link_sync.log (runs as hmo user)
2. git hooks (.git/hooks/post-merge + post-checkout on 246 repo):
   auto re-link after git operations
3. Manual fallback: sync_profile_scripts.sh (now self-logging)

dev-spec red line #6 updated: SSOT rule now documents the three layers
and states breakage only happens at deploy time.
2026-07-20 20:27:11 +08:00

10 lines
447 B
Bash

#!/bin/bash
# git post-merge / post-checkout hook — 自动重建硬链接
# git 操作(merge/checkout/rebase)会替换文件、破坏硬链接,钩子自动修复
REPO="/home/hmo/MoFin"
if [ -x "$REPO/deploy/profile-scripts/sync_profile_scripts.sh" ]; then
bash "$REPO/deploy/profile-scripts/sync_profile_scripts.sh" >/dev/null 2>&1
echo "$(date '+%F %T') auto-synced by git $1 hook" >> "$REPO/gateway/logs/link_sync.log"
fi
exit 0