summaryrefslogtreecommitdiffstats
path: root/util/git-hooks
diff options
context:
space:
mode:
authorStefan Tauner <stefan.tauner@gmx.at>2017-10-01 19:15:10 +0200
committerNico Huber <nico.h@gmx.de>2017-10-05 10:45:21 +0000
commit3a937b77320f24b648306d90063df39cd08cf633 (patch)
treec9bdf39db6adebb02195aa922613423851c75f36 /util/git-hooks
parent68b5f00930132c12c98705e7728765171142d2ef (diff)
downloadflashrom-3a937b77320f24b648306d90063df39cd08cf633.tar.gz
flashrom-3a937b77320f24b648306d90063df39cd08cf633.tar.bz2
flashrom-3a937b77320f24b648306d90063df39cd08cf633.zip
fixup! Convert flashrom to git
- update the commit-msg hook to the latest one provided by Gerrit. However, disable the (new) code that would avoid adding Change-IDs to fixup/squash commits as needed on the staging branch Change-Id: I2f2d7ae58dcd7d3e55959e18fe664df10bc3cc41 Signed-off-by: Stefan Tauner <stefan.tauner@gmx.at> Reviewed-on: https://review.coreboot.org/21832 Reviewed-by: Nico Huber <nico.h@gmx.de> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'util/git-hooks')
-rwxr-xr-xutil/git-hooks/commit-msg35
1 files changed, 27 insertions, 8 deletions
diff --git a/util/git-hooks/commit-msg b/util/git-hooks/commit-msg
index 82f0581ce..3b3d54155 100755
--- a/util/git-hooks/commit-msg
+++ b/util/git-hooks/commit-msg
@@ -1,6 +1,8 @@
#!/bin/sh
#
-# Part of Gerrit Code Review (http://code.google.com/p/gerrit/)
+# Change-ID amending from Gerrit Code Review 2.14.2
+#
+# Part of Gerrit Code Review (https://www.gerritcodereview.com/)
#
# Copyright (C) 2009 The Android Open Source Project
#
@@ -17,14 +19,16 @@
# limitations under the License.
#
-CHANGE_ID_AFTER="Bug|Issue"
+unset GREP_OPTIONS
+
+CHANGE_ID_AFTER="Bug|Depends-On|Issue|Test|Feature|Fixes|Fixed|Staging-ID"
MSG="$1"
# Check for, and add if missing, a unique Change-Id
#
add_ChangeId() {
clean_message=`sed -e '
- /^diff --git a\/.*/{
+ /^diff --git .*/{
s///
q
}
@@ -36,8 +40,19 @@ add_ChangeId() {
return
fi
+ # *Do* add Change-Id to temp commits (original code bails out here)
+ # if echo "$clean_message" | head -1 | grep -q '^\(fixup\|squash\)!'
+ # then
+ # return
+ # fi
+
+ if test "false" = "`git config --bool --get gerrit.createChangeId`"
+ then
+ return
+ fi
+
# Does Change-Id: already exist? if so, exit (no change).
- if grep -i '^Change-Id: I[0-9a-f]\{40\}$' "$MSG" >/dev/null
+ if grep -i '^Change-Id:' "$MSG" >/dev/null
then
return
fi
@@ -50,6 +65,10 @@ add_ChangeId() {
AWK=/usr/xpg4/bin/awk
fi
+ # Get core.commentChar from git config or use default symbol
+ commentChar=`git config --get core.commentChar`
+ commentChar=${commentChar:-#}
+
# How this works:
# - parse the commit message as (textLine+ blankLine*)*
# - assume textLine+ to be a footer until proven otherwise
@@ -68,13 +87,13 @@ add_ChangeId() {
blankLines = 0
}
- # Skip lines starting with "#" without any spaces before it.
- /^#/ { next }
+ # Skip lines starting with commentChar without any spaces before it.
+ /^'"$commentChar"'/ { next }
# Skip the line starting with the diff command and everything after it,
# up to the end of the file, assuming it is only patch data.
# If more than one line before the diff was empty, strip all but one.
- /^diff --git a/ {
+ /^diff --git / {
blankLines = 0
while (getline) { }
next
@@ -151,7 +170,7 @@ add_ChangeId() {
if (unprinted) {
print "Change-Id: I'"$id"'"
}
- }' "$MSG" > $T && mv $T "$MSG" || rm -f $T
+ }' "$MSG" > "$T" && mv "$T" "$MSG" || rm -f "$T"
}
_gen_ChangeIdInput() {
echo "tree `git write-tree`"