mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-10 08:52:39 +01:00
Support 'arc:exec(command)' in base-commit DSL
Summary: Allow users to run a command to determine the base revision of the commit range. Test Plan: Ran stuff like `arc which --show-base --base 'arc:exec(ls)'` and got the expected results. Reviewers: dschleimer, csilvers, btrahan, vrana Reviewed By: csilvers CC: aran Maniphest Tasks: T1233 Differential Revision: https://secure.phabricator.com/D2830
This commit is contained in:
parent
7f640b9db9
commit
887c3484a7
1 changed files with 14 additions and 1 deletions
|
@ -32,7 +32,7 @@ final class ArcanistBaseCommitParser {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
$spec = preg_split('/[ ,]/', $raw_spec);
|
$spec = preg_split('/\s*,\s*/', $raw_spec);
|
||||||
$spec = array_filter($spec);
|
$spec = array_filter($spec);
|
||||||
|
|
||||||
foreach ($spec as $rule) {
|
foreach ($spec as $rule) {
|
||||||
|
@ -164,6 +164,19 @@ final class ArcanistBaseCommitParser {
|
||||||
case 'outgoing':
|
case 'outgoing':
|
||||||
return $this->api->resolveBaseCommitRule($rule, $source);
|
return $this->api->resolveBaseCommitRule($rule, $source);
|
||||||
default:
|
default:
|
||||||
|
$matches = null;
|
||||||
|
if (preg_match('/^exec\((.*)\)$/', $name, $matches)) {
|
||||||
|
$root = $this->api->getWorkingCopyIdentity()->getProjectRoot();
|
||||||
|
$future = new ExecFuture($matches[1]);
|
||||||
|
$future->setCWD($root);
|
||||||
|
list($err, $stdout) = $future->resolve();
|
||||||
|
if (!$err) {
|
||||||
|
return trim($stdout);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
throw new ArcanistUsageException(
|
throw new ArcanistUsageException(
|
||||||
"Base commit rule '{$rule}' (from source '{$source}') ".
|
"Base commit rule '{$rule}' (from source '{$source}') ".
|
||||||
"is not a recognized rule.");
|
"is not a recognized rule.");
|
||||||
|
|
Loading…
Reference in a new issue