54245f188a
Four git hooks, tracked in .githooks and wired with core.hooksPath so a fresh clone gets them with one config line. pre-commit refuses master and refuses more than 300 changed lines in non-markdown files. Markdown is exempt because docs land as one batch. commit-msg requires (V-<id>), not (#<id>), because Gitea autolinks # to its own issues and that is the wrong tracker. post-checkout records the parent branch, since git does not track where a branch was cut from and the PR needs the base. pre-push opens the PR with tea and never blocks. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
35 lines
988 B
Bash
Executable File
35 lines
988 B
Bash
Executable File
#!/bin/sh
|
|
# Git does not remember which branch a branch was cut from, and the PR needs it.
|
|
# Record it once, at creation, best effort.
|
|
#
|
|
# Args: <prev-head> <new-head> <branch-flag>. branch-flag is 1 for a branch
|
|
# switch, 0 for a file checkout.
|
|
|
|
prev=$1
|
|
flag=$3
|
|
|
|
[ "$flag" = "1" ] || exit 0
|
|
|
|
branch=$(git symbolic-ref --short HEAD 2>/dev/null) || exit 0
|
|
[ -n "$branch" ] || exit 0
|
|
|
|
dir="$(git rev-parse --git-dir)/maven-parent"
|
|
key=$(printf '%s' "$branch" | tr '/' '_')
|
|
|
|
# Already recorded, or we are on a long-lived branch. Leave it alone.
|
|
[ -f "$dir/$key" ] && exit 0
|
|
case "$branch" in master|main) exit 0 ;; esac
|
|
|
|
# name-rev resolves the sha we came from back to a branch name. It picks the
|
|
# closest ref, which is right often enough to beat guessing master.
|
|
parent=$(git name-rev --name-only --refs='refs/heads/*' "$prev" 2>/dev/null |
|
|
sed 's/[~^].*//')
|
|
|
|
case "$parent" in
|
|
""|undefined|"$branch") parent=master ;;
|
|
esac
|
|
|
|
mkdir -p "$dir"
|
|
printf '%s\n' "$parent" > "$dir/$key"
|
|
exit 0
|