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:
Loic d'Anterroches
2009-01-17 18:46:26 +01:00
parent 61bc7a70b6
commit 835eab9c24
5 changed files with 66 additions and 2 deletions

View File

@@ -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.
*

View File

@@ -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.

View File

@@ -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();