Add support of renamed file for IDF_Scm_Git::getchanges()

This commit is contained in:
William MARTIN 2011-02-25 11:10:10 +01:00
parent c486fe98fb
commit cc89a7e6f8

View File

@ -56,7 +56,7 @@ class IDF_Scm_Git extends IDF_Scm
*/ */
public function getChanges($commit) public function getChanges($commit)
{ {
$cmd = sprintf('GIT_DIR=%s '.Pluf::f('git_path', 'git').' show %s --name-status --pretty="format:" --diff-filter="[A|D|M|R]"', $cmd = sprintf('GIT_DIR=%s '.Pluf::f('git_path', 'git').' show %s --name-status --pretty="format:" --diff-filter="[A|D|M|R]" -M',
escapeshellarg($this->repo), escapeshellarg($this->repo),
escapeshellarg($commit)); escapeshellarg($commit));
$out = array(); $out = array();
@ -75,20 +75,23 @@ class IDF_Scm_Git extends IDF_Scm
$line = trim($line); $line = trim($line);
if ($line != '') { if ($line != '') {
$action = $line[0]; $action = $line[0];
$filename = trim(substr($line, 1));
if ($action == 'A') { if ($action == 'A') {
$filename = trim(substr($line, 1));
$return->additions[] = $filename; $return->additions[] = $filename;
} else if ($action == 'D') { } else if ($action == 'D') {
$filename = trim(substr($line, 1));
$return->deletions[] = $filename; $return->deletions[] = $filename;
} else if ($action == 'M') { } else if ($action == 'M') {
$filename = trim(substr($line, 1));
$return->patches[] = $filename; $return->patches[] = $filename;
} else if ($action == 'R') { } else if ($action == 'R') {
$return->renames[] = $filename; $matches = split ("\t", $line);
$return->renames[$matches[1]] = $matches[2];
} }
} }
} }
return $return; return $return;
} }