hooks: branch guard, 300-line cap, task ref, auto PR (V-445)
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>
This commit is contained in:
Executable
+29
@@ -0,0 +1,29 @@
|
||||
#!/bin/sh
|
||||
# Cut a task branch and record the branch it came from, so pre-push can open
|
||||
# the PR against the right base.
|
||||
#
|
||||
# scripts/task-branch.sh 359 narrow-single-token
|
||||
# -> task/359-narrow-single-token, parent recorded as the current branch
|
||||
|
||||
set -eu
|
||||
|
||||
if [ $# -lt 2 ]; then
|
||||
echo "usage: $0 <vikunja-id> <slug>" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
id=$1
|
||||
shift
|
||||
slug=$(printf '%s' "$*" | tr '[:upper:] ' '[:lower:]-' | tr -cd 'a-z0-9-')
|
||||
|
||||
parent=$(git symbolic-ref --short HEAD)
|
||||
branch="task/$id-$slug"
|
||||
|
||||
git checkout -b "$branch"
|
||||
|
||||
dir="$(git rev-parse --git-dir)/maven-parent"
|
||||
mkdir -p "$dir"
|
||||
printf '%s\n' "$parent" > "$dir/$(printf '%s' "$branch" | tr '/' '_')"
|
||||
|
||||
echo "$branch, cut from $parent"
|
||||
echo "Commits on it must end with (V-$id)."
|
||||
Reference in New Issue
Block a user