Files
CursorInitGeneral/.cursor/changelog/tools/install-git-hooks.sh

17 lines
695 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/sh
# install-git-hooks.sh — 把 changelog 的 pre-commit / post-merge git hook 装进本仓库。
# git hook 不随仓库分发,每个克隆都要跑一次本脚本(幂等)。
# 用法sh .cursor/changelog/tools/install-git-hooks.sh
set -e
HOOKS_DIR=$(git rev-parse --git-path hooks 2>/dev/null) || { echo "不在 git 仓库内"; exit 1; }
mkdir -p "$HOOKS_DIR"
SRC=$(CDPATH= cd -- "$(dirname -- "$0")/git-hooks" && pwd)
for name in pre-commit post-merge; do
cp -f "$SRC/$name" "$HOOKS_DIR/$name"
chmod +x "$HOOKS_DIR/$name"
echo "installed: $HOOKS_DIR/$name"
done
echo "完成。git hook 已安装pre-commit 重建并纳入视图post-merge 合并后重建)。"