Changeset View
Changeset View
Standalone View
Standalone View
tools/tools/git/hooks/prepare-commit-msg
#!/bin/sh | #!/bin/sh | ||||
# prepare-commit-msg: Prepare a commit message upon `git commit` for the | # prepare-commit-msg: Prepare a commit message upon `git commit` for the | ||||
# user to edit. A script (rather than a static template) is used, so | # user to edit. A script (rather than a static template) is used, so | ||||
# that we can insert our template text other than at the top of the | # that we can insert our template text other than at the top of the | ||||
# message. | # message. | ||||
# | # | ||||
# Install by copying into the git hooks directory - for example, | # Install by copying into the git hooks directory - for example, | ||||
# cp tools/tools/git/hooks/prepare-commit-msg .git/hooks/ | # cp tools/tools/git/hooks/prepare-commit-msg .git/hooks/ | ||||
case "$2" in | case "$2" in | ||||
commit|message) | commit|message) | ||||
# It appears git invokes this script for interactive rebase but does | # It appears git invokes this script for interactive rebase but does | ||||
# not remove commented lines, so just exit if we're not called with the | # not remove commented lines, so just exit if we're not called with the | ||||
# default (comment-containing) template. | # default (comment-containing) template. | ||||
egrep -q '^#' "$1" || return 0 | grep -E -q '^#' "$1" || exit 0 | ||||
;; | ;; | ||||
template) | template) | ||||
return 0 | exit 0 | ||||
;; | ;; | ||||
merge) | merge) | ||||
return 0 | exit 0 | ||||
;; | ;; | ||||
esac | esac | ||||
outfile=$(mktemp /tmp/freebsd-git-commit.XXXXXXXX) | outfile=$(mktemp /tmp/freebsd-git-commit.XXXXXXXX) | ||||
# Create a commit message template from three parts: | # Create a commit message template from three parts: | ||||
# | # | ||||
# 1. The beginning of the git-provided template (up to the first comment-only | # 1. The beginning of the git-provided template (up to the first comment-only | ||||
Show All 22 Lines | |||||
# Relnotes: <Set to 'yes' for mention in release notes.> | # Relnotes: <Set to 'yes' for mention in release notes.> | ||||
# Security: <Vulnerability reference (one per line) or description.> | # Security: <Vulnerability reference (one per line) or description.> | ||||
# Sponsored by: <If the change was sponsored by an organization.> | # Sponsored by: <If the change was sponsored by an organization.> | ||||
# Pull Request: <https://github.com/freebsd/<repo>/pull/###> | # Pull Request: <https://github.com/freebsd/<repo>/pull/###> | ||||
# Differential Revision: <https://reviews.freebsd.org/D###> | # Differential Revision: <https://reviews.freebsd.org/D###> | ||||
# | # | ||||
# "Pull Request" and "Differential Revision" require the *full* GitHub or | # "Pull Request" and "Differential Revision" require the *full* GitHub or | ||||
# Phabricator URL. | # Phabricator URL. | ||||
$(awk '/^#$/,EOF' $1) | $(awk '/^#$/,EOF' "$1") | ||||
EOF | EOF | ||||
mv $outfile $1 | mv "$outfile" "$1" |