1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-11-28 01:06:17 +00:00

.hooks/prepare-commit-msg: Enhance commit-msg hook.

If a single port is updated, the hook now pre-fills in an appropriate
subject line.

(cherry picked from commit 5147b3b5e1)
This commit is contained in:
Mathieu Arnold 2021-06-04 13:53:38 +02:00
parent d1c97575f0
commit aa2e788130
No known key found for this signature in database
GPG Key ID: 29EB0902911D7E02

View File

@ -28,6 +28,25 @@ esac
outfile=$(mktemp /tmp/freebsd-git-commit.XXXXXXXX)
exec 3> "$outfile"
if [ -z "$3" ]
then
what=$(git diff-index --name-only --cached --diff-filter=ACMR HEAD|sed -Ee 's/^([^\/]+\/[^\/]+).*/\1/'|sort -u|xargs)
case $what in
*\ *)
# More than one port, do nothing
;;
*)
# One port, prepare the commit message.
{
echo "# Uncomment and add a short description of why things changed."
echo "# $what: "
echo
} >&3
;;
esac
fi
# Create a commit message template from three parts:
#
# 1. The beginning of the git-provided template (up to the first comment-only