final move of files
[web.mtrack] / MTrack / CommitCheck / SingleIssue.php
1 <?php 
2 require_once 'Interface/CommitListener.php';
3
4 class MTrackCommitCheck_SingleIssue implements IMTrackCommitListener 
5 {
6   
7
8     function vetoCommit($msg, $files, $actions,$checker)
9     {
10         // checks for XXXX #123 - XXXX YYYY
11         if (!preg_match("/^\s*[a-z]+\s+#[0-9]+\s+-\s+[a-z]+\s/i", $msg)) {
12             $msg= trim($msg);
13             return "Commit messages must include the exact issue being fixed and in the format\n\n'fix #123 - some description'\n\n You used\n'$msg'";
14         }
15         // we need to reject
16         //asdfasdf #123, 234 ,34 
17         
18         $ar = array();
19         preg_match_all("/[0-9]+/i", $msg,$ar);
20         if (count($ar[0]) !=  1) {
21             return "Fix only one bug with each commit - 
22 remove the changes that do not relate to this issue and commit again.";
23         }
24         
25          
26         return true;
27     }
28
29     function postCommit($msg, $files, $actions) {
30         return true;
31     }
32 }