From 887c3484a7f92e033f30f9fdc3a2de2fd42e769f Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 22 Jun 2012 08:13:06 -0700 Subject: [PATCH] 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 --- src/parser/ArcanistBaseCommitParser.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/parser/ArcanistBaseCommitParser.php b/src/parser/ArcanistBaseCommitParser.php index d1d41f39..04681077 100644 --- a/src/parser/ArcanistBaseCommitParser.php +++ b/src/parser/ArcanistBaseCommitParser.php @@ -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."); -- 2.43.0