Skip to content

Commit 9ba7509

Browse files
author
Marcus Sorensen
committed
Summary: add git prepare-commit-msg file
Detail: CloudStack committers can optionally use this file to prepopulate their commits with a standard form. The idea was that it would help us get better commit messages. It is set up locally up by running the following from the root of the repo: 'ln -s ../../tools/git/prepare-commit-msg .git/hooks/prepare-commit-msg' Additionally, a different prepare-commit-msg could potentially be committed for each branch and the link will always point to the one that's checked out. BUG-ID : none Reviewed-by: Marcus Sorensen <marcus@betterservers.com> Reported-by: Rohit Yadav <rohit.yadav@citrix.com> Signed-off-by: Marcus Sorensen <marcus@betterservers.com> 1350596087 -0600
1 parent 640aba7 commit 9ba7509

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

tools/git/prepare-commit-msg

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/bin/sh
2+
#
3+
# An example hook script to prepare the commit log message.
4+
# Called by "git commit" with the name of the file that has the
5+
# commit message, followed by the description of the commit
6+
# message's source. The hook's purpose is to edit the commit
7+
# message file. If the hook fails with a non-zero status,
8+
# the commit is aborted.
9+
#
10+
# To enable this hook, rename this file to "prepare-commit-msg".
11+
12+
# This hook includes three examples. The first comments out the
13+
# "Conflicts:" part of a merge commit.
14+
#
15+
# The second includes the output of "git diff --name-status -r"
16+
# into the message, just before the "git status" output. It is
17+
# commented because it doesn't cope with --amend or with squashed
18+
# commits.
19+
#
20+
# The third example adds a Signed-off-by line to the message, that can
21+
# still be edited. This is rarely a good idea.
22+
23+
#case "$2,$3" in
24+
# merge,)
25+
# /usr/bin/perl -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;;
26+
27+
# ,|template,)
28+
# /usr/bin/perl -i.bak -pe '
29+
# print "\n" . `git diff --cached --name-status -r`
30+
# if /^#/ && $first++ == 0' "$1" ;;
31+
32+
# *) ;;
33+
#esac
34+
35+
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
36+
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
37+
38+
cat <<EOF > $1
39+
################################# 80 chars #####################################
40+
# The following is an example of how to fill out the above form. Please limit
41+
# your formatting to 80 cols.
42+
#
43+
# Summary: One line description of commit, followed by blank line
44+
#
45+
# Detail: Multi-line description, followed by blank line
46+
#
47+
# BUG-ID: CLOUDSTACK-9999
48+
# Reviewed-by: Bar Barlington <bar@example.com>, Foo McFooson <foo@example.com>
49+
# Reported-by: Baz Bazelli <baz@example.com>
50+
# Signed-off-by: You <you@yourdomain.com>
51+
#
52+
$ORIGINAL
53+
EOF
54+
55+
SOB=$(git var GIT_AUTHOR_IDENT)
56+
57+
sed -i "1s/^/################################# 80 chars #####################################\n\
58+
Summary: \n\n\
59+
Detail: \n\n\
60+
BUG-ID : \n\
61+
Reviewed-by: \n\
62+
Reported-by: \n\
63+
Signed-off-by: ${SOB}\n\n/" $1
64+

0 commit comments

Comments
 (0)