Merge branch 'ks/prepare-commit-msg-sample'
Remove an example that is now obsolete from a sample hook, and improve an old example in it that added a sign-off manually to use the interpret-trailers command. * ks/prepare-commit-msg-sample: hook: add a simple first example hook: add sign-off using "interpret-trailers" hook: name the positional variables hook: cleanup script
This commit is contained in:
commit
127f98f42b
@ -121,8 +121,8 @@ it is not suppressed by the `--no-verify` option. A non-zero exit
|
|||||||
means a failure of the hook and aborts the commit. It should not
|
means a failure of the hook and aborts the commit. It should not
|
||||||
be used as replacement for pre-commit hook.
|
be used as replacement for pre-commit hook.
|
||||||
|
|
||||||
The sample `prepare-commit-msg` hook that comes with Git comments
|
The sample `prepare-commit-msg` hook that comes with Git removes the
|
||||||
out the `Conflicts:` part of a merge's commit message.
|
help message found in the commented portion of the commit template.
|
||||||
|
|
||||||
commit-msg
|
commit-msg
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
#
|
#
|
||||||
# To enable this hook, rename this file to "prepare-commit-msg".
|
# To enable this hook, rename this file to "prepare-commit-msg".
|
||||||
|
|
||||||
# This hook includes three examples. The first comments out the
|
# This hook includes three examples. The first one removes the
|
||||||
# "Conflicts:" part of a merge commit.
|
# "# Please enter the commit message..." help message.
|
||||||
#
|
#
|
||||||
# The second includes the output of "git diff --name-status -r"
|
# The second includes the output of "git diff --name-status -r"
|
||||||
# into the message, just before the "git status" output. It is
|
# into the message, just before the "git status" output. It is
|
||||||
@ -20,17 +20,23 @@
|
|||||||
# The third example adds a Signed-off-by line to the message, that can
|
# The third example adds a Signed-off-by line to the message, that can
|
||||||
# still be edited. This is rarely a good idea.
|
# still be edited. This is rarely a good idea.
|
||||||
|
|
||||||
case "$2,$3" in
|
COMMIT_MSG_FILE=$1
|
||||||
merge,)
|
COMMIT_SOURCE=$2
|
||||||
@PERL_PATH@ -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;;
|
SHA1=$3
|
||||||
|
|
||||||
# ,|template,)
|
@PERL_PATH@ -i.bak -ne 'print unless(m/^. Please enter the commit message/..m/^#$/)' "$COMMIT_MSG_FILE"
|
||||||
# @PERL_PATH@ -i.bak -pe '
|
|
||||||
# print "\n" . `git diff --cached --name-status -r`
|
|
||||||
# if /^#/ && $first++ == 0' "$1" ;;
|
|
||||||
|
|
||||||
*) ;;
|
# case "$COMMIT_SOURCE,$SHA1" in
|
||||||
esac
|
# ,|template,)
|
||||||
|
# @PERL_PATH@ -i.bak -pe '
|
||||||
|
# print "\n" . `git diff --cached --name-status -r`
|
||||||
|
# if /^#/ && $first++ == 0' "$COMMIT_MSG_FILE" ;;
|
||||||
|
# *) ;;
|
||||||
|
# esac
|
||||||
|
|
||||||
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
|
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
|
||||||
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
|
# git interpret-trailers --in-place --trailer "$SOB" "$COMMIT_MSG_FILE"
|
||||||
|
# if test -z "$COMMIT_SOURCE"
|
||||||
|
# then
|
||||||
|
# @PERL_PATH@ -i.bak -pe 'print "\n" if !$first_line++' "$COMMIT_MSG_FILE"
|
||||||
|
# fi
|
||||||
|
Loading…
Reference in New Issue
Block a user