-
Notifications
You must be signed in to change notification settings - Fork 0
/
redmine-commit
executable file
·39 lines (27 loc) · 978 Bytes
/
redmine-commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/php
<?php
/*
This hook create redmine hash to let redmine follow our changes
Copy this file into ./git/hooks/prepare-commit-msg and then set as executable file.
You can now just create branch eg feature/12345 and then make commit:
git commit -m 'some comment'
above will set commit message to: some comment reds #123456
and thx to that redmine can follow our changes
*/
function writeMessage($bugNumber, $oldMessage) {
global $argv;
$message = $oldMessage;
if ($bugNumber) {
$message .= ' refs #' . $bugNumber;
}
file_put_contents($argv[1], $message);
}
$message = trim(file_get_contents($argv[1]));
$currentBranch = trim(exec('git symbolic-ref --short HEAD'));
$ar = explode('/', $currentBranch);
$bugNumber = end($ar);
//cheking if last piece of branch name is number - this should be redmine bug/task number.
if (!is_numeric($bugNumber)){
exit;
}
writeMessage($bugNumber, $message);