2 require_once 'Interface/CommitListener.php';
4 class MTrackCommitCheck_UnixLineBreak implements IMTrackCommitListener
7 function vetoCommit($msg, $files, $actions, $checker)
9 // should only have a list of files which have been updated/added. (not deleted)
11 if (count($files) > 30) {
12 // to many files.. we can not check that amount without causing serious delays in commits
16 foreach ($files as $filename) {
17 $pi = pathinfo($filename);
18 switch($pi['extension']) {
21 $fp = $checker->bridge->getFileStream($filename);
23 $res = $this->checkLineBreaks($filename, $fp);
27 $fp = null; // remove stream.
31 return $ret ? implode("\n", $ret) : true;
34 function postCommit($msg, $files, $actions) {
37 function checkLineBreaks($filename, $fp)
40 $contents = stream_get_contents($fp);
41 if (preg_match("/\r+/", $contents)) {
42 return "Use Unix line endings only in $filename";