diff options
Diffstat (limited to 'hooks/commit-msg')
-rwxr-xr-x | hooks/commit-msg | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/hooks/commit-msg b/hooks/commit-msg index d8f009b6..40ac237a 100755 --- a/hooks/commit-msg +++ b/hooks/commit-msg | |||
@@ -1,6 +1,7 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | # From Gerrit Code Review 2.12.1 | ||
2 | # | 3 | # |
3 | # Part of Gerrit Code Review (http://code.google.com/p/gerrit/) | 4 | # Part of Gerrit Code Review (https://www.gerritcodereview.com/) |
4 | # | 5 | # |
5 | # Copyright (C) 2009 The Android Open Source Project | 6 | # Copyright (C) 2009 The Android Open Source Project |
6 | # | 7 | # |
@@ -19,7 +20,7 @@ | |||
19 | 20 | ||
20 | unset GREP_OPTIONS | 21 | unset GREP_OPTIONS |
21 | 22 | ||
22 | CHANGE_ID_AFTER="Bug|Issue" | 23 | CHANGE_ID_AFTER="Bug|Issue|Test" |
23 | MSG="$1" | 24 | MSG="$1" |
24 | 25 | ||
25 | # Check for, and add if missing, a unique Change-Id | 26 | # Check for, and add if missing, a unique Change-Id |
@@ -38,6 +39,12 @@ add_ChangeId() { | |||
38 | return | 39 | return |
39 | fi | 40 | fi |
40 | 41 | ||
42 | # Do not add Change-Id to temp commits | ||
43 | if echo "$clean_message" | head -1 | grep -q '^\(fixup\|squash\)!' | ||
44 | then | ||
45 | return | ||
46 | fi | ||
47 | |||
41 | if test "false" = "`git config --bool --get gerrit.createChangeId`" | 48 | if test "false" = "`git config --bool --get gerrit.createChangeId`" |
42 | then | 49 | then |
43 | return | 50 | return |
@@ -57,6 +64,10 @@ add_ChangeId() { | |||
57 | AWK=/usr/xpg4/bin/awk | 64 | AWK=/usr/xpg4/bin/awk |
58 | fi | 65 | fi |
59 | 66 | ||
67 | # Get core.commentChar from git config or use default symbol | ||
68 | commentChar=`git config --get core.commentChar` | ||
69 | commentChar=${commentChar:-#} | ||
70 | |||
60 | # How this works: | 71 | # How this works: |
61 | # - parse the commit message as (textLine+ blankLine*)* | 72 | # - parse the commit message as (textLine+ blankLine*)* |
62 | # - assume textLine+ to be a footer until proven otherwise | 73 | # - assume textLine+ to be a footer until proven otherwise |
@@ -75,8 +86,8 @@ add_ChangeId() { | |||
75 | blankLines = 0 | 86 | blankLines = 0 |
76 | } | 87 | } |
77 | 88 | ||
78 | # Skip lines starting with "#" without any spaces before it. | 89 | # Skip lines starting with commentChar without any spaces before it. |
79 | /^#/ { next } | 90 | /^'"$commentChar"'/ { next } |
80 | 91 | ||
81 | # Skip the line starting with the diff command and everything after it, | 92 | # Skip the line starting with the diff command and everything after it, |
82 | # up to the end of the file, assuming it is only patch data. | 93 | # up to the end of the file, assuming it is only patch data. |