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>
34 lines
1.1 KiB
Bash
Executable File
34 lines
1.1 KiB
Bash
Executable File
#!/bin/sh
|
|
# Open the PR on first push of a task branch, against the branch it was cut
|
|
# from. A commit is too early for this. A push means the work is shareable.
|
|
#
|
|
# Never fatal: a missing tea login or an unreachable Gitea must not block a
|
|
# push. It prints the command instead.
|
|
|
|
branch=$(git symbolic-ref --short HEAD 2>/dev/null) || exit 0
|
|
case "$branch" in ""|master|main) exit 0 ;; esac
|
|
|
|
command -v tea >/dev/null 2>&1 || exit 0
|
|
|
|
dir="$(git rev-parse --git-dir)/maven-parent"
|
|
key=$(printf '%s' "$branch" | tr '/' '_')
|
|
parent=$(cat "$dir/$key" 2>/dev/null)
|
|
[ -n "$parent" ] || parent=master
|
|
|
|
if tea pr list --output simple 2>/dev/null | grep -q "[[:space:]]$branch\$"; then
|
|
exit 0
|
|
fi
|
|
|
|
title=$(git log -1 --format=%s)
|
|
body=$(git log "$parent..$branch" --format='- %s' 2>/dev/null)
|
|
|
|
if tea pr create --head "$branch" --base "$parent" \
|
|
--title "$title" --description "$body" >/dev/null 2>&1; then
|
|
echo "pre-push: opened PR $branch -> $parent"
|
|
else
|
|
echo "pre-push: could not open the PR. Run it yourself:" >&2
|
|
echo " tea pr create --head $branch --base $parent --title \"$title\"" >&2
|
|
fi
|
|
|
|
exit 0
|