Changeset View
Changeset View
Standalone View
Standalone View
src/workflow/ArcanistDiffWorkflow.php
| Show First 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | $arguments = array( | ||||
| 'paramtype' => 'file', | 'paramtype' => 'file', | ||||
| 'help' => pht( | 'help' => pht( | ||||
| 'When creating a revision, read revision information '. | 'When creating a revision, read revision information '. | ||||
| 'from this file.'), | 'from this file.'), | ||||
| ), | ), | ||||
| 'use-commit-message' => array( | 'use-commit-message' => array( | ||||
| 'supports' => array( | 'supports' => array( | ||||
| 'git', | 'git', | ||||
| // TODO: Support mercurial. | // TODO: Support mercurial. | ||||
Lint: TODO Comment: This comment has a TODO. | |||||
| ), | ), | ||||
| 'short' => 'C', | 'short' => 'C', | ||||
| 'param' => 'commit', | 'param' => 'commit', | ||||
| 'help' => pht('Read revision information from a specific commit.'), | 'help' => pht('Read revision information from a specific commit.'), | ||||
| 'conflicts' => array( | 'conflicts' => array( | ||||
| 'only' => null, | 'only' => null, | ||||
| 'preview' => null, | 'preview' => null, | ||||
| 'update' => null, | 'update' => null, | ||||
| ▲ Show 20 Lines • Show All 269 Lines • ▼ Show 20 Lines | $arguments = array( | ||||
| 'base' => array( | 'base' => array( | ||||
| 'param' => 'rules', | 'param' => 'rules', | ||||
| 'help' => pht('Additional rules for determining base revision.'), | 'help' => pht('Additional rules for determining base revision.'), | ||||
| 'nosupport' => array( | 'nosupport' => array( | ||||
| 'svn' => pht('Subversion does not use base commits.'), | 'svn' => pht('Subversion does not use base commits.'), | ||||
| ), | ), | ||||
| 'supports' => array('git', 'hg'), | 'supports' => array('git', 'hg'), | ||||
| ), | ), | ||||
| 'cache' => array( | |||||
| 'param' => 'bool', | |||||
| 'help' => pht( | |||||
| '%d to disable lint cache, %d to enable (default).', | |||||
| 0, | |||||
| 1), | |||||
| 'passthru' => array( | |||||
| 'lint' => true, | |||||
| ), | |||||
| ), | |||||
| 'coverage' => array( | 'coverage' => array( | ||||
| 'help' => pht('Always enable coverage information.'), | 'help' => pht('Always enable coverage information.'), | ||||
| 'conflicts' => array( | 'conflicts' => array( | ||||
| 'no-coverage' => null, | 'no-coverage' => null, | ||||
| ), | ), | ||||
| 'passthru' => array( | 'passthru' => array( | ||||
| 'unit' => true, | 'unit' => true, | ||||
| ), | ), | ||||
| ▲ Show 20 Lines • Show All 239 Lines • ▼ Show 20 Lines | if ($head_commit !== null) { | ||||
| $repository_api->setHeadCommit($head_commit); | $repository_api->setHeadCommit($head_commit); | ||||
| } | } | ||||
| } | } | ||||
| private function runDiffSetupBasics() { | private function runDiffSetupBasics() { | ||||
| $output_json = $this->getArgument('json'); | $output_json = $this->getArgument('json'); | ||||
| if ($output_json) { | if ($output_json) { | ||||
| // TODO: We should move this to a higher-level and put an indirection | // TODO: We should move this to a higher-level and put an indirection | ||||
Lint: TODO Comment This comment has a TODO. Lint: TODO Comment: This comment has a TODO. | |||||
| // layer between echoing stuff and stdout. | // layer between echoing stuff and stdout. | ||||
| ob_start(); | ob_start(); | ||||
| } | } | ||||
| if ($this->requiresWorkingCopy()) { | if ($this->requiresWorkingCopy()) { | ||||
| $repository_api = $this->getRepositoryAPI(); | $repository_api = $this->getRepositoryAPI(); | ||||
| if ($this->getArgument('add-all')) { | if ($this->getArgument('add-all')) { | ||||
| $this->setCommitMode(self::COMMIT_ENABLE); | $this->setCommitMode(self::COMMIT_ENABLE); | ||||
| ▲ Show 20 Lines • Show All 572 Lines • ▼ Show 20 Lines | try { | ||||
| if ($repository_api->supportsCommitRanges()) { | if ($repository_api->supportsCommitRanges()) { | ||||
| $argv[] = '--rev'; | $argv[] = '--rev'; | ||||
| $argv[] = $repository_api->getBaseCommit(); | $argv[] = $repository_api->getBaseCommit(); | ||||
| } | } | ||||
| $lint_workflow = $this->buildChildWorkflow('lint', $argv); | $lint_workflow = $this->buildChildWorkflow('lint', $argv); | ||||
| if ($this->shouldAmend()) { | if ($this->shouldAmend()) { | ||||
| // TODO: We should offer to create a checkpoint commit. | // TODO: We should offer to create a checkpoint commit. | ||||
Lint: TODO Comment This comment has a TODO. Lint: TODO Comment: This comment has a TODO. | |||||
| $lint_workflow->setShouldAmendChanges(true); | $lint_workflow->setShouldAmendChanges(true); | ||||
| } | } | ||||
| $lint_result = $lint_workflow->run(); | $lint_result = $lint_workflow->run(); | ||||
| switch ($lint_result) { | switch ($lint_result) { | ||||
| case ArcanistLintWorkflow::RESULT_OKAY: | case ArcanistLintWorkflow::RESULT_OKAY: | ||||
| if ($this->getArgument('advice') && | if ($this->getArgument('advice') && | ||||
| ▲ Show 20 Lines • Show All 686 Lines • ▼ Show 20 Lines | private function parseCommitMessagesIntoFields(array $local) { | ||||
| $faux_message = array(); | $faux_message = array(); | ||||
| if ($this->getArgument('reviewers')) { | if ($this->getArgument('reviewers')) { | ||||
| $faux_message[] = pht('Reviewers: %s', $this->getArgument('reviewers')); | $faux_message[] = pht('Reviewers: %s', $this->getArgument('reviewers')); | ||||
| } | } | ||||
| if ($this->getArgument('cc')) { | if ($this->getArgument('cc')) { | ||||
| $faux_message[] = pht('CC: %s', $this->getArgument('cc')); | $faux_message[] = pht('CC: %s', $this->getArgument('cc')); | ||||
| } | } | ||||
| // NOTE: For now, this isn't a real field, so it just ends up as the first | |||||
| // part of the summary. | |||||
| $depends_ref = $this->getDependsOnRevisionRef(); | |||||
| if ($depends_ref) { | |||||
| $faux_message[] = pht( | |||||
| 'Depends on %s. ', | |||||
| $depends_ref->getMonogram()); | |||||
| } | |||||
| // See T12069. After T10312, the first line of a message is always parsed | // See T12069. After T10312, the first line of a message is always parsed | ||||
| // as a title. Add a placeholder so "Reviewers" and "CC" are never the | // as a title. Add a placeholder so "Reviewers" and "CC" are never the | ||||
| // first line. | // first line. | ||||
| $placeholder_title = pht('<placeholder>'); | $placeholder_title = pht('<placeholder>'); | ||||
| if ($faux_message) { | if ($faux_message) { | ||||
| array_unshift($faux_message, $placeholder_title); | array_unshift($faux_message, $placeholder_title); | ||||
| $faux_message = implode("\n\n", $faux_message); | $faux_message = implode("\n\n", $faux_message); | ||||
| ▲ Show 20 Lines • Show All 350 Lines • ▼ Show 20 Lines | if (!$this->isRawDiffSource()) { | ||||
| } else if ($repository_api instanceof ArcanistMercurialAPI) { | } else if ($repository_api instanceof ArcanistMercurialAPI) { | ||||
| $bookmark = $repository_api->getActiveBookmark(); | $bookmark = $repository_api->getActiveBookmark(); | ||||
| $svn_info = $repository_api->getSubversionInfo(); | $svn_info = $repository_api->getSubversionInfo(); | ||||
| $repo_uuid = idx($svn_info, 'uuid'); | $repo_uuid = idx($svn_info, 'uuid'); | ||||
| $base_path = idx($svn_info, 'base_path', $base_path); | $base_path = idx($svn_info, 'base_path', $base_path); | ||||
| $base_revision = idx($svn_info, 'base_revision', $base_revision); | $base_revision = idx($svn_info, 'base_revision', $base_revision); | ||||
| // TODO: provide parent info | // TODO: provide parent info | ||||
Lint: TODO Comment This comment has a TODO. Lint: TODO Comment: This comment has a TODO. | |||||
| } | } | ||||
| } | } | ||||
| $data = array( | $data = array( | ||||
| 'sourceMachine' => php_uname('n'), | 'sourceMachine' => php_uname('n'), | ||||
| 'sourcePath' => $source_path, | 'sourcePath' => $source_path, | ||||
| 'branch' => $branch, | 'branch' => $branch, | ||||
| ▲ Show 20 Lines • Show All 564 Lines • ▼ Show 20 Lines | private function updateAutotargets($diff_phid, $unit_result) { | ||||
| } | } | ||||
| try { | try { | ||||
| foreach (new FutureIterator($futures) as $future) { | foreach (new FutureIterator($futures) as $future) { | ||||
| $future->resolve(); | $future->resolve(); | ||||
| } | } | ||||
| return true; | return true; | ||||
| } catch (Exception $ex) { | } catch (Exception $ex) { | ||||
| // TODO: Eventually, we should expect these to succeed if we get this | // TODO: Eventually, we should expect these to succeed if we get this | ||||
Lint: TODO Comment This comment has a TODO. Lint: TODO Comment: This comment has a TODO. | |||||
| // far, but just log errors for now. | // far, but just log errors for now. | ||||
| phlog($ex); | phlog($ex); | ||||
| return false; | return false; | ||||
| } | } | ||||
| } | } | ||||
| private function getDependsOnRevisionRef() { | |||||
| $api = $this->getRepositoryAPI(); | |||||
| $base_ref = $api->getBaseCommitRef(); | |||||
| $state_ref = $this->newWorkingCopyStateRef() | |||||
| ->setCommitRef($base_ref); | |||||
| $this->newRefQuery(array($state_ref)) | |||||
| ->needHardpoints( | |||||
| array( | |||||
| 'revisionRefs', | |||||
| )) | |||||
| ->execute(); | |||||
| $revision_refs = $state_ref->getRevisionRefs(); | |||||
| $viewer_phid = $this->getUserPHID(); | |||||
| foreach ($revision_refs as $key => $revision_ref) { | |||||
| // Don't automatically depend on closed revisions. | |||||
| if ($revision_ref->isClosed()) { | |||||
| unset($revision_refs[$key]); | |||||
| continue; | |||||
| } | |||||
| // Don't automatically depend on revisions authored by other users. | |||||
| if ($revision_ref->getAuthorPHID() != $viewer_phid) { | |||||
| continue; | |||||
Not Done Inline ActionsAm I missing something here or should this condition also have the unset($revision_refs[$key] bit in it? jmeador: Am I missing something here or should this condition also have the `unset($revision_refs[$key]`… | |||||
Not Done Inline ActionsThanks, D18766. epriestley: Thanks, D18766. | |||||
| } | |||||
Not Done Inline ActionsIs there some tricky reason why this would be a bad thing? Seems like depending on someone else's revision is a reasonable workflow. amckinley: Is there some tricky reason why this would be a bad thing? Seems like depending on someone… | |||||
| } | |||||
| if (!$revision_refs) { | |||||
| return null; | |||||
| } | |||||
| if (count($revision_refs) > 1) { | |||||
| return null; | |||||
| } | |||||
| return head($revision_refs); | |||||
| } | |||||
| } | } | ||||
This comment has a TODO.