Fixed issue 93 by preventing the display of a large commit diff.
Still needs to implement the equivalent for subversion and mercurial, maybe with a simple command $scm->isCommitLarge($commit).
This commit is contained in:
@@ -286,6 +286,39 @@ class IDF_Scm_Git
|
||||
return $out[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get commit size.
|
||||
*
|
||||
* Get the sum of all the added/removed lines and the number of
|
||||
* affected files.
|
||||
*
|
||||
* @param string Commit ('HEAD')
|
||||
* @return array array(added, removed, affected)
|
||||
*/
|
||||
public function getCommitSize($commit='HEAD')
|
||||
{
|
||||
$cmd = sprintf('GIT_DIR=%s git log --numstat -1 --pretty=format:%s %s',
|
||||
escapeshellarg($this->repo),
|
||||
"'commit %H%n'",
|
||||
escapeshellarg($commit));
|
||||
$out = array();
|
||||
IDF_Scm::exec($cmd, $out);
|
||||
$affected = count($out) - 2;
|
||||
$added = 0;
|
||||
$removed = 0;
|
||||
$c=0;
|
||||
foreach ($out as $line) {
|
||||
$c++;
|
||||
if ($c < 3) {
|
||||
continue;
|
||||
}
|
||||
list($a, $r, $f) = preg_split("/[\s]+/", $line, 3, PREG_SPLIT_NO_EMPTY);
|
||||
$added+=$a;
|
||||
$removed+=$r;
|
||||
}
|
||||
return array($added, $removed, $affected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get latest changes.
|
||||
*
|
||||
|
@@ -302,6 +302,19 @@ class IDF_Scm_Mercurial
|
||||
return $out[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get commit size.
|
||||
*
|
||||
* Get the sum of all the added/removed lines and the number of
|
||||
* affected files.
|
||||
*
|
||||
* @param string Commit ('HEAD')
|
||||
* @return array array(added, removed, affected)
|
||||
*/
|
||||
public function getCommitSize($commit='HEAD')
|
||||
{
|
||||
return array(0, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get latest changes.
|
||||
|
@@ -291,6 +291,20 @@ class IDF_Scm_Svn
|
||||
return (object) $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get commit size.
|
||||
*
|
||||
* Get the sum of all the added/removed lines and the number of
|
||||
* affected files.
|
||||
*
|
||||
* @param string Commit ('HEAD')
|
||||
* @return array array(added, removed, affected)
|
||||
*/
|
||||
public function getCommitSize($commit='HEAD')
|
||||
{
|
||||
return array(0, 0, 0);
|
||||
}
|
||||
|
||||
private function getDiff($rev='HEAD')
|
||||
{
|
||||
$res = array();
|
||||
|
Reference in New Issue
Block a user