Changeset View
Changeset View
Standalone View
Standalone View
src/workflow/ArcanistWhichWorkflow.php
Show First 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | return array( | ||||
), | ), | ||||
'show-base' => array( | 'show-base' => array( | ||||
'help' => 'Print base commit only and exit.', | 'help' => 'Print base commit only and exit.', | ||||
'nosupport' => array( | 'nosupport' => array( | ||||
'svn' => 'Subversion does not use base commits.', | 'svn' => 'Subversion does not use base commits.', | ||||
), | ), | ||||
'supports' => array('git', 'hg'), | 'supports' => array('git', 'hg'), | ||||
), | ), | ||||
'head' => array( | |||||
'param' => 'commit', | |||||
'help' => 'specify the head commit.' | |||||
), | |||||
'*' => 'commit', | '*' => 'commit', | ||||
); | ); | ||||
} | } | ||||
public function run() { | public function run() { | ||||
$console = PhutilConsole::getConsole(); | $console = PhutilConsole::getConsole(); | ||||
$this->printRepositorySection(); | $this->printRepositorySection(); | ||||
$console->writeOut("\n"); | $console->writeOut("\n"); | ||||
$repository_api = $this->getRepositoryAPI(); | $repository_api = $this->getRepositoryAPI(); | ||||
$arg_commit = $this->getArgument('commit'); | $arg_commit = $this->getArgument('commit'); | ||||
if (count($arg_commit)) { | if (count($arg_commit)) { | ||||
$this->parseBaseCommitArgument($arg_commit); | $this->parseBaseCommitArgument($arg_commit); | ||||
} | } | ||||
$arg = $arg_commit ? ' '.head($arg_commit) : ''; | $arg = $arg_commit ? ' '.head($arg_commit) : ''; | ||||
$repository_api->setBaseCommitArgumentRules( | $repository_api->setBaseCommitArgumentRules( | ||||
$this->getArgument('base', '')); | $this->getArgument('base', '')); | ||||
if ($repository_api->supportsCommitRanges()) { | $supports_ranges = $repository_api->supportsCommitRanges(); | ||||
if ($this->getArgument('head')) { | |||||
if ($supports_ranges === false) { | |||||
throw new Exception('--head is not supported in this VCS'); | |||||
} | |||||
$head_commit = $this->getArgument('head'); | |||||
$arg .= " --head {$head_commit}"; | |||||
epriestley: For consistency, prefer `{$x}` over `${x}`. | |||||
$repository_api->setHeadCommit($head_commit); | |||||
} | |||||
if ($supports_ranges) { | |||||
$relative = $repository_api->getBaseCommit(); | $relative = $repository_api->getBaseCommit(); | ||||
if ($this->getArgument('show-base')) { | if ($this->getArgument('show-base')) { | ||||
echo $relative."\n"; | echo $relative."\n"; | ||||
return 0; | return 0; | ||||
} | } | ||||
$info = $repository_api->getLocalCommitInformation(); | $info = $repository_api->getLocalCommitInformation(); | ||||
Show All 11 Lines | if ($supports_ranges) { | ||||
} | } | ||||
$explanation = $repository_api->getBaseCommitExplanation(); | $explanation = $repository_api->getBaseCommitExplanation(); | ||||
$relative_summary = $repository_api->getCommitSummary($relative); | $relative_summary = $repository_api->getCommitSummary($relative); | ||||
$relative = substr($relative, 0, 16); | $relative = substr($relative, 0, 16); | ||||
if ($repository_api instanceof ArcanistGitAPI) { | if ($repository_api instanceof ArcanistGitAPI) { | ||||
$command = "git diff {$relative}..HEAD"; | $head = $this->getArgument('head', 'HEAD'); | ||||
$command = "git diff {$relative}..{$head}"; | |||||
Not Done Inline ActionsThis should use the specified HEAD. epriestley: This should use the specified HEAD. | |||||
} else if ($repository_api instanceof ArcanistMercurialAPI) { | } else if ($repository_api instanceof ArcanistMercurialAPI) { | ||||
$command = "hg diff --rev {$relative}"; | $command = "hg diff --rev {$relative}"; | ||||
} else { | } else { | ||||
throw new Exception('Unknown VCS!'); | throw new Exception('Unknown VCS!'); | ||||
} | } | ||||
echo phutil_console_wrap( | echo phutil_console_wrap( | ||||
phutil_console_format( | phutil_console_format( | ||||
▲ Show 20 Lines • Show All 120 Lines • Show Last 20 Lines |
For consistency, prefer {$x} over ${x}.