1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-22 06:42:41 +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:
epriestley 2012-06-22 08:13:06 -07:00
parent 7f640b9db9
commit 887c3484a7

View file

@ -32,7 +32,7 @@ final class ArcanistBaseCommitParser {
return array();
}
$spec = preg_split('/[ ,]/', $raw_spec);
$spec = preg_split('/\s*,\s*/', $raw_spec);
$spec = array_filter($spec);
foreach ($spec as $rule) {
@ -164,6 +164,19 @@ final class ArcanistBaseCommitParser {
case 'outgoing':
return $this->api->resolveBaseCommitRule($rule, $source);
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(
"Base commit rule '{$rule}' (from source '{$source}') ".
"is not a recognized rule.");