annotate myTools/.git/hooks/prepare-commit-msg.sample @ 6:f9f71cf4c3e3

Uploaded
author mrvollger
date Thu, 11 Dec 2014 15:42:44 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
f9f71cf4c3e3 Uploaded
mrvollger
parents:
diff changeset
1 #!/bin/sh
f9f71cf4c3e3 Uploaded
mrvollger
parents:
diff changeset
2 #
f9f71cf4c3e3 Uploaded
mrvollger
parents:
diff changeset
3 # An example hook script to prepare the commit log message.
f9f71cf4c3e3 Uploaded
mrvollger
parents:
diff changeset
4 # Called by "git commit" with the name of the file that has the
f9f71cf4c3e3 Uploaded
mrvollger
parents:
diff changeset
5 # commit message, followed by the description of the commit
f9f71cf4c3e3 Uploaded
mrvollger
parents:
diff changeset
6 # message's source. The hook's purpose is to edit the commit
f9f71cf4c3e3 Uploaded
mrvollger
parents:
diff changeset
7 # message file. If the hook fails with a non-zero status,
f9f71cf4c3e3 Uploaded
mrvollger
parents:
diff changeset
8 # the commit is aborted.
f9f71cf4c3e3 Uploaded
mrvollger
parents:
diff changeset
9 #
f9f71cf4c3e3 Uploaded
mrvollger
parents:
diff changeset
10 # To enable this hook, rename this file to "prepare-commit-msg".
f9f71cf4c3e3 Uploaded
mrvollger
parents:
diff changeset
11
f9f71cf4c3e3 Uploaded
mrvollger
parents:
diff changeset
12 # This hook includes three examples. The first comments out the
f9f71cf4c3e3 Uploaded
mrvollger
parents:
diff changeset
13 # "Conflicts:" part of a merge commit.
f9f71cf4c3e3 Uploaded
mrvollger
parents:
diff changeset
14 #
f9f71cf4c3e3 Uploaded
mrvollger
parents:
diff changeset
15 # The second includes the output of "git diff --name-status -r"
f9f71cf4c3e3 Uploaded
mrvollger
parents:
diff changeset
16 # into the message, just before the "git status" output. It is
f9f71cf4c3e3 Uploaded
mrvollger
parents:
diff changeset
17 # commented because it doesn't cope with --amend or with squashed
f9f71cf4c3e3 Uploaded
mrvollger
parents:
diff changeset
18 # commits.
f9f71cf4c3e3 Uploaded
mrvollger
parents:
diff changeset
19 #
f9f71cf4c3e3 Uploaded
mrvollger
parents:
diff changeset
20 # The third example adds a Signed-off-by line to the message, that can
f9f71cf4c3e3 Uploaded
mrvollger
parents:
diff changeset
21 # still be edited. This is rarely a good idea.
f9f71cf4c3e3 Uploaded
mrvollger
parents:
diff changeset
22
f9f71cf4c3e3 Uploaded
mrvollger
parents:
diff changeset
23 case "$2,$3" in
f9f71cf4c3e3 Uploaded
mrvollger
parents:
diff changeset
24 merge,)
f9f71cf4c3e3 Uploaded
mrvollger
parents:
diff changeset
25 /usr/bin/perl -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;;
f9f71cf4c3e3 Uploaded
mrvollger
parents:
diff changeset
26
f9f71cf4c3e3 Uploaded
mrvollger
parents:
diff changeset
27 # ,|template,)
f9f71cf4c3e3 Uploaded
mrvollger
parents:
diff changeset
28 # /usr/bin/perl -i.bak -pe '
f9f71cf4c3e3 Uploaded
mrvollger
parents:
diff changeset
29 # print "\n" . `git diff --cached --name-status -r`
f9f71cf4c3e3 Uploaded
mrvollger
parents:
diff changeset
30 # if /^#/ && $first++ == 0' "$1" ;;
f9f71cf4c3e3 Uploaded
mrvollger
parents:
diff changeset
31
f9f71cf4c3e3 Uploaded
mrvollger
parents:
diff changeset
32 *) ;;
f9f71cf4c3e3 Uploaded
mrvollger
parents:
diff changeset
33 esac
f9f71cf4c3e3 Uploaded
mrvollger
parents:
diff changeset
34
f9f71cf4c3e3 Uploaded
mrvollger
parents:
diff changeset
35 # SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
f9f71cf4c3e3 Uploaded
mrvollger
parents:
diff changeset
36 # grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"