mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
Update commit-msg hook
Modified in https://gerrit-review.googlesource.com/c/gerrit/+/394841. Change-Id: I381e48fbdb92b33454219dd9d945a1756e551a77 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/395577 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Orgad Shaneh <orgads@gmail.com> Commit-Queue: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Ernesto Rodriguez <guez30nesto@gmail.com>
This commit is contained in:
parent
0dd0a830b0
commit
a50c4e3bc0
@ -1,5 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# From Gerrit Code Review 3.6.1 c67916dbdc07555c44e32a68f92ffc484b9b34f0
|
# From Gerrit Code Review 3.10.0 d5403dbf335ba7d48977fc95170c3f7027c34659
|
||||||
#
|
#
|
||||||
# Part of Gerrit Code Review (https://www.gerritcodereview.com/)
|
# Part of Gerrit Code Review (https://www.gerritcodereview.com/)
|
||||||
#
|
#
|
||||||
@ -31,14 +31,21 @@ if test ! -f "$1" ; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Do not create a change id if requested
|
# Do not create a change id if requested
|
||||||
if test "false" = "$(git config --bool --get gerrit.createChangeId)" ; then
|
create_setting=$(git config --get gerrit.createChangeId)
|
||||||
exit 0
|
case "$create_setting" in
|
||||||
fi
|
false)
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
always)
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# Do not create a change id for squash/fixup commits.
|
||||||
|
if head -n1 "$1" | LC_ALL=C grep -q '^[a-z][a-z]*! '; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
# Do not create a change id for squash commits.
|
|
||||||
if head -n1 "$1" | grep -q '^squash! '; then
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if git rev-parse --verify HEAD >/dev/null 2>&1; then
|
if git rev-parse --verify HEAD >/dev/null 2>&1; then
|
||||||
refhash="$(git rev-parse HEAD)"
|
refhash="$(git rev-parse HEAD)"
|
||||||
@ -51,7 +58,7 @@ dest="$1.tmp.${random}"
|
|||||||
|
|
||||||
trap 'rm -f "$dest" "$dest-2"' EXIT
|
trap 'rm -f "$dest" "$dest-2"' EXIT
|
||||||
|
|
||||||
if ! git stripspace --strip-comments < "$1" > "${dest}" ; then
|
if ! cat "$1" | sed -e '/>8/q' | git stripspace --strip-comments > "${dest}" ; then
|
||||||
echo "cannot strip comments from $1"
|
echo "cannot strip comments from $1"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@ -65,7 +72,7 @@ reviewurl="$(git config --get gerrit.reviewUrl)"
|
|||||||
if test -n "${reviewurl}" ; then
|
if test -n "${reviewurl}" ; then
|
||||||
token="Link"
|
token="Link"
|
||||||
value="${reviewurl%/}/id/I$random"
|
value="${reviewurl%/}/id/I$random"
|
||||||
pattern=".*/id/I[0-9a-f]\{40\}$"
|
pattern=".*/id/I[0-9a-f]\{40\}"
|
||||||
else
|
else
|
||||||
token="Change-Id"
|
token="Change-Id"
|
||||||
value="I$random"
|
value="I$random"
|
||||||
@ -92,7 +99,7 @@ fi
|
|||||||
# Avoid the --where option which only appeared in Git 2.15
|
# Avoid the --where option which only appeared in Git 2.15
|
||||||
if ! git -c trailer.where=before interpret-trailers \
|
if ! git -c trailer.where=before interpret-trailers \
|
||||||
--trailer "Signed-off-by: $token: $value" < "$dest-2" |
|
--trailer "Signed-off-by: $token: $value" < "$dest-2" |
|
||||||
sed -re "s/^Signed-off-by: ($token: )/\1/" \
|
sed -e "s/^Signed-off-by: \($token: \)/\1/" \
|
||||||
-e "/^Signed-off-by: SENTINEL/d" > "$dest" ; then
|
-e "/^Signed-off-by: SENTINEL/d" > "$dest" ; then
|
||||||
echo "cannot insert $token line in $1"
|
echo "cannot insert $token line in $1"
|
||||||
exit 1
|
exit 1
|
||||||
|
Loading…
Reference in New Issue
Block a user