final move of files
[web.mtrack] / MTrack / CommitCheck / BlankLines.php
1 <?php 
2 require_once 'Interface/CommitListener.php';
3
4 class MTrackCommitCheck_BlankLines implements IMTrackCommitListener 
5 {
6   
7     function vetoCommit($msg, $files, $actions, $checker)
8     {
9         // should only have a list of files which have been updated/added. (not deleted)
10         $ret = array();
11         if (!method_exists($checker->bridge, 'getDiffStream')) { // kludge - we should use interface....
12             return true;
13         }
14         $fp = $checker->bridge->getDiffStream();
15         $diff = stream_get_contents($fp);
16         $lines = explode("\n",$contents);
17         $seq = 0;
18         $total = 0;
19         
20         // probably a CRLF fix....
21         if (count($lines) > 100) {
22             return;
23         }
24         
25         foreach($lines as $l) {
26             $ll = trim($l);
27             if ($l != '+') {
28                 $seq =0;
29                 continue;
30             }
31             // got blannk line
32             $seq++;
33             
34             if ($seq > 2) {
35                 return "You are adding more than 2 blank lines - please remove the new blank lines you added and try again.";
36             }
37         }
38         
39          
40          
41        return true;
42     }
43
44     function postCommit($msg, $files, $actions) {
45         return true;
46     }
47     
48 }