annotate .git/hooks/commit-msg.sample @ 2:801f5e934011 draft default tip

Uploaded
author devteam
date Thu, 23 Oct 2014 11:40:52 -0400
parents b76a4f17bbbb
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
b76a4f17bbbb Uploaded
devteam
parents:
diff changeset
1 #!/bin/sh
b76a4f17bbbb Uploaded
devteam
parents:
diff changeset
2 #
b76a4f17bbbb Uploaded
devteam
parents:
diff changeset
3 # An example hook script to check the commit log message.
b76a4f17bbbb Uploaded
devteam
parents:
diff changeset
4 # Called by "git commit" with one argument, the name of the file
b76a4f17bbbb Uploaded
devteam
parents:
diff changeset
5 # that has the commit message. The hook should exit with non-zero
b76a4f17bbbb Uploaded
devteam
parents:
diff changeset
6 # status after issuing an appropriate message if it wants to stop the
b76a4f17bbbb Uploaded
devteam
parents:
diff changeset
7 # commit. The hook is allowed to edit the commit message file.
b76a4f17bbbb Uploaded
devteam
parents:
diff changeset
8 #
b76a4f17bbbb Uploaded
devteam
parents:
diff changeset
9 # To enable this hook, rename this file to "commit-msg".
b76a4f17bbbb Uploaded
devteam
parents:
diff changeset
10
b76a4f17bbbb Uploaded
devteam
parents:
diff changeset
11 # Uncomment the below to add a Signed-off-by line to the message.
b76a4f17bbbb Uploaded
devteam
parents:
diff changeset
12 # Doing this in a hook is a bad idea in general, but the prepare-commit-msg
b76a4f17bbbb Uploaded
devteam
parents:
diff changeset
13 # hook is more suited to it.
b76a4f17bbbb Uploaded
devteam
parents:
diff changeset
14 #
b76a4f17bbbb Uploaded
devteam
parents:
diff changeset
15 # SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
b76a4f17bbbb Uploaded
devteam
parents:
diff changeset
16 # grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
b76a4f17bbbb Uploaded
devteam
parents:
diff changeset
17
b76a4f17bbbb Uploaded
devteam
parents:
diff changeset
18 # This example catches duplicate Signed-off-by lines.
b76a4f17bbbb Uploaded
devteam
parents:
diff changeset
19
b76a4f17bbbb Uploaded
devteam
parents:
diff changeset
20 test "" = "$(grep '^Signed-off-by: ' "$1" |
b76a4f17bbbb Uploaded
devteam
parents:
diff changeset
21 sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
b76a4f17bbbb Uploaded
devteam
parents:
diff changeset
22 echo >&2 Duplicate Signed-off-by lines.
b76a4f17bbbb Uploaded
devteam
parents:
diff changeset
23 exit 1
b76a4f17bbbb Uploaded
devteam
parents:
diff changeset
24 }