mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-12-24 14:30:55 +01:00
Provide repository API method for getting changed files
Test Plan: print_r($api->getChangedFiles('HEAD~36')); // Under Git. Verified that deleted files are false. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T2038 Differential Revision: https://secure.phabricator.com/D3941
This commit is contained in:
parent
d3f351caae
commit
58e3e928d1
4 changed files with 50 additions and 0 deletions
|
@ -533,6 +533,21 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
|
|||
->setDelimiter("\0");
|
||||
}
|
||||
|
||||
public function getChangedFiles($since_commit) {
|
||||
list($stdout) = $this->execxLocal(
|
||||
'diff --name-status -z %s',
|
||||
$since_commit);
|
||||
$return = array();
|
||||
foreach (array_chunk(explode("\0", $stdout), 2) as $val) {
|
||||
if (count($val) != 2) {
|
||||
break;
|
||||
}
|
||||
list($status, $path) = $val;
|
||||
$return[$path] = ($status == 'D' ? false : true);
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function getBlame($path) {
|
||||
// TODO: 'git blame' supports --porcelain and we should probably use it.
|
||||
list($stdout) = $this->execxLocal(
|
||||
|
|
|
@ -251,6 +251,21 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
|
|||
return new LinesOfALargeExecFuture($future);
|
||||
}
|
||||
|
||||
public function getChangedFiles($since_commit) {
|
||||
list($stdout) = $this->execxLocal(
|
||||
'status --rev %s -0',
|
||||
$since_commit);
|
||||
$return = array();
|
||||
foreach (explode("\0", $stdout) as $val) {
|
||||
$match = null;
|
||||
if (preg_match('/^(.) (.+)/', $val, $match)) {
|
||||
list(, $status, $path) = $match;
|
||||
$return[$path] = ($status == 'R' ? false : true);
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function getBlame($path) {
|
||||
list($stdout) = $this->execxLocal(
|
||||
'annotate -u -v -c --rev %s -- %s',
|
||||
|
|
|
@ -188,6 +188,10 @@ abstract class ArcanistRepositoryAPI {
|
|||
throw new ArcanistCapabilityNotSupportedException($this);
|
||||
}
|
||||
|
||||
public function getChangedFiles($since_commit) {
|
||||
throw new ArcanistCapabilityNotSupportedException($this);
|
||||
}
|
||||
|
||||
public function amendCommit($message) {
|
||||
throw new ArcanistCapabilityNotSupportedException($this);
|
||||
}
|
||||
|
|
|
@ -473,6 +473,22 @@ EODIFF;
|
|||
array($this, 'filterFiles'));
|
||||
}
|
||||
|
||||
public function getChangedFiles($since_commit) {
|
||||
// TODO: Handle paths with newlines.
|
||||
list($stdout) = $this->execxLocal(
|
||||
'diff --revision %s:HEAD',
|
||||
$since_commit);
|
||||
$return = array();
|
||||
foreach (explode("\n", $stdout) as $val) {
|
||||
$match = null;
|
||||
if (preg_match('/^(.)\S*\s+(.+)/', $val, $match)) {
|
||||
list(, $status, $path) = $match;
|
||||
$return[$path] = ($status == 'D' ? false : true);
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function filterFiles($path) {
|
||||
// NOTE: SVN uses '/' also on Windows.
|
||||
if ($path == '' || substr($path, -1) == '/') {
|
||||
|
|
Loading…
Reference in a new issue