6. Gitolite Common Hooks
● /usr/share/gitolite/hooks/common/*
● post-receive:
...
# read input objects
while read oldrev newrev ref
do
# get the commit information
subj=`git show -s --format="%s" $newrev`
diff=`git show $newrev...$oldrev`
msgs="$subj
$diff"
# excute pre-write perl script to sync mantis
/home/gitolite/git2mantis.pl "$msgs"
...
done
7. Gitolite Common Hooks
● Execute "gl-setup" to push common hooks to
each repository
● Check whether hook scripts are pushed to
each repositories
● Location: ~/repositories/*/hooks/*
9. Intermediate Programs
● Mantis Server: 192.168.0.1:
/var/www/mantis/scripts/git-checkin.php
...
# Parsing the input to get issue number
$t_commit_regexp = "/issueD*(d*)/";
$t_line = readline("");
iif (preg_match( $t_commit_regexp, $t_line, $t_matches ) == 0) {
echo "Comment does not reference any issues.n";
exit( 0 );
}
$t_issues[0] = $t_matches[1];
...
# Call mantis helper function to insert issue note
$t_issue_id = $t_issues[0];
helper_call_custom_function( 'checkin', array( $t_issue_id, $t_comment,
$t_history_old_value, $t_history_new_value, false );
10. Send SMTP Mail
● Modify ~/.gitolite/conf/gitolite.conf to add
mailing list with "hooks.mailinglist"
...
repo testing
config hooks.mailinglist = "alex.lin@innocomm.com, cc.
chen@innocomm.com, cookie.liu@innocomm.com,
...
jiahe.jou@innocomm.com, weili.luo@innocomm.com"
RW+ = @all
R = daemon
R = gitweb
...
11. Send SMTP Mail
● Add the following to post-receive
...
# get mailing list by git config
recipients=`git config hooks.mailinglist`
# execute pre-write script to send mail
/home/gitolite/git2mail.py "$subj" "$diff" "$recipients"
...