diff options
| author | Mike Bjorge <mbjorge@google.com> | 2016-02-29 11:48:15 -0800 |
|---|---|---|
| committer | David Pursehouse <david.pursehouse@sonymobile.com> | 2016-03-14 10:08:33 +0900 |
| commit | 9322964d141d470df70ba6fb2310653ead25c652 (patch) | |
| tree | 0bef31866e5316caa3f25540cf79575a4917e5f4 /hooks | |
| parent | 4aa4b211c62a8f01abfe1953b4274af69d374ecf (diff) | |
| download | git-repo-9322964d141d470df70ba6fb2310653ead25c652.tar.gz | |
Update commit-msg hook to version from Gerrit 2.12.1
Change-Id: I31b74aba998f8e83f370a759218777f2557a8872
Diffstat (limited to 'hooks')
| -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. |
