projects
/
web.mtrack
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
3f21e27
)
inc/CommitCheck/BlankLines.php
author
Alan Knowles
<alan@akbkhome.com>
Thu, 27 Jan 2011 06:51:38 +0000
(14:51 +0800)
committer
Alan Knowles
<alan@akbkhome.com>
Thu, 27 Jan 2011 06:51:38 +0000
(14:51 +0800)
inc/CommitCheck/BlankLines.php
patch
|
blob
|
history
diff --git
a/inc/CommitCheck/BlankLines.php
b/inc/CommitCheck/BlankLines.php
index
df106c5
..
3344cd4
100644
(file)
--- a/
inc/CommitCheck/BlankLines.php
+++ b/
inc/CommitCheck/BlankLines.php
@@
-8,22
+8,31
@@
class MTrackCommitCheck_BlankLines implements IMTrackCommitListener
{
// should only have a list of files which have been updated/added. (not deleted)
$ret = array();
{
// should only have a list of files which have been updated/added. (not deleted)
$ret = array();
- foreach ($files as $filename) {
- $pi = pathinfo($filename);
- switch($pi['extension']) {
- case 'php':
- case 'html':
- $fp = $checker->bridge->getFileStream($filename);
-
- $res = $this->checkBlanks($filename, $fp);
- if ($res !== true) {
- $ret[] = $res;
- }
- $fp = null; // remove stream.
- }
+ if (!method_exists($checker->bridge, 'getDiffStream')) {
+ return true;
}
}
+ $fp = $checker->bridge->getDiffStream();
+ $diff = stream_get_contents($fp);
+ $lines = explode("\n",$contents);
+ $seq = 0;
+ $total = 0;
+ foreach($lines as $l) {
+ $ll = trim($l);
+ if ($l != '+') {
+ $seq =0;
+ continue;
+ }
+ // got blannk line
+ $seq++;
+ $total++;
+ if ($seq > 2) {
+ return "You are adding more than 2 blank lines - please remove the new blank lines you added and try again.";
+ }
+ }
+
+
- return
$ret ? implode("\n", $ret) :
true;
+ return true;
}
function postCommit($msg, $files, $actions) {
}
function postCommit($msg, $files, $actions) {