Changeset View
Changeset View
Standalone View
Standalone View
src/workflow/ArcanistDiffWorkflow.php
Show All 15 Lines | final class ArcanistDiffWorkflow extends ArcanistWorkflow { | ||||
private $excuses = array('lint' => null, 'unit' => null); | private $excuses = array('lint' => null, 'unit' => null); | ||||
private $testResults; | private $testResults; | ||||
private $diffID; | private $diffID; | ||||
private $revisionID; | private $revisionID; | ||||
private $haveUncommittedChanges = false; | private $haveUncommittedChanges = false; | ||||
private $diffPropertyFutures = array(); | private $diffPropertyFutures = array(); | ||||
private $commitMessageFromRevision; | private $commitMessageFromRevision; | ||||
private $hitAutotargets; | private $hitAutotargets; | ||||
private $revisionTransactions; | |||||
private $revisionIsDraft; | |||||
const STAGING_PUSHED = 'pushed'; | const STAGING_PUSHED = 'pushed'; | ||||
const STAGING_USER_SKIP = 'user.skip'; | const STAGING_USER_SKIP = 'user.skip'; | ||||
const STAGING_DIFF_RAW = 'diff.raw'; | const STAGING_DIFF_RAW = 'diff.raw'; | ||||
const STAGING_REPOSITORY_UNKNOWN = 'repository.unknown'; | const STAGING_REPOSITORY_UNKNOWN = 'repository.unknown'; | ||||
const STAGING_REPOSITORY_UNAVAILABLE = 'repository.unavailable'; | const STAGING_REPOSITORY_UNAVAILABLE = 'repository.unavailable'; | ||||
const STAGING_REPOSITORY_UNSUPPORTED = 'repository.unsupported'; | const STAGING_REPOSITORY_UNSUPPORTED = 'repository.unsupported'; | ||||
const STAGING_REPOSITORY_UNCONFIGURED = 'repository.unconfigured'; | const STAGING_REPOSITORY_UNCONFIGURED = 'repository.unconfigured'; | ||||
▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | $arguments = array( | ||||
'supports' => array( | 'supports' => array( | ||||
'git', | 'git', | ||||
// TODO: Support mercurial. | // TODO: Support mercurial. | ||||
), | ), | ||||
'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, | |||||
'update' => null, | 'update' => null, | ||||
), | ), | ||||
), | ), | ||||
'edit' => array( | 'edit' => array( | ||||
'supports' => array( | 'supports' => array( | ||||
'git', | 'git', | ||||
'hg', | 'hg', | ||||
), | ), | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | $arguments = array( | ||||
), | ), | ||||
'create' => array( | 'create' => array( | ||||
'help' => pht('Always create a new revision.'), | 'help' => pht('Always create a new revision.'), | ||||
'conflicts' => array( | 'conflicts' => array( | ||||
'edit' => pht( | 'edit' => pht( | ||||
'%s can not be used with %s.', | '%s can not be used with %s.', | ||||
'--create', | '--create', | ||||
'--edit'), | '--edit'), | ||||
'only' => pht( | 'only' => pht( | ||||
'%s can not be used with %s.', | '%s can not be used with %s.', | ||||
'--create', | '--create', | ||||
'--only'), | '--only'), | ||||
'preview' => pht( | |||||
'%s can not be used with %s.', | |||||
'--create', | |||||
'--preview'), | |||||
'update' => pht( | 'update' => pht( | ||||
'%s can not be used with %s.', | '%s can not be used with %s.', | ||||
'--create', | '--create', | ||||
'--update'), | '--update'), | ||||
), | ), | ||||
), | ), | ||||
'update' => array( | 'update' => array( | ||||
'param' => 'revision_id', | 'param' => 'revision_id', | ||||
'help' => pht('Always update a specific revision.'), | 'help' => pht('Always update a specific revision.'), | ||||
), | ), | ||||
'draft' => array( | |||||
'help' => pht( | |||||
'Create a draft revision so you can look over your changes before '. | |||||
'involving anyone else. Other users will not be notified about the '. | |||||
'revision until you later use "Request Review" to publish it. You '. | |||||
'can still share the draft by giving someone the link.'), | |||||
'conflicts' => array( | |||||
'edit' => null, | |||||
'only' => null, | |||||
'update' => null, | |||||
), | |||||
), | |||||
'nounit' => array( | 'nounit' => array( | ||||
'help' => pht('Do not run unit tests.'), | 'help' => pht('Do not run unit tests.'), | ||||
), | ), | ||||
'nolint' => array( | 'nolint' => array( | ||||
'help' => pht('Do not run lint.'), | 'help' => pht('Do not run lint.'), | ||||
'conflicts' => array( | 'conflicts' => array( | ||||
'lintall' => pht('%s suppresses lint.', '--nolint'), | 'lintall' => pht('%s suppresses lint.', '--nolint'), | ||||
'advice' => pht('%s suppresses lint.', '--nolint'), | 'advice' => pht('%s suppresses lint.', '--nolint'), | ||||
'apply-patches' => pht('%s suppresses lint.', '--nolint'), | 'apply-patches' => pht('%s suppresses lint.', '--nolint'), | ||||
'never-apply-patches' => pht('%s suppresses lint.', '--nolint'), | 'never-apply-patches' => pht('%s suppresses lint.', '--nolint'), | ||||
), | ), | ||||
), | ), | ||||
'only' => array( | 'only' => array( | ||||
'help' => pht( | 'help' => pht( | ||||
'Only generate a diff, without running lint, unit tests, or other '. | |||||
'auxiliary steps. See also %s.', | |||||
'--preview'), | |||||
'conflicts' => array( | |||||
'preview' => null, | |||||
'message' => pht('%s does not affect revisions.', '--only'), | |||||
'edit' => pht('%s does not affect revisions.', '--only'), | |||||
'lintall' => pht('%s suppresses lint.', '--only'), | |||||
'advice' => pht('%s suppresses lint.', '--only'), | |||||
'apply-patches' => pht('%s suppresses lint.', '--only'), | |||||
'never-apply-patches' => pht('%s suppresses lint.', '--only'), | |||||
), | |||||
), | |||||
'preview' => array( | |||||
'help' => pht( | |||||
'Instead of creating or updating a revision, only create a diff, '. | 'Instead of creating or updating a revision, only create a diff, '. | ||||
'which you may later attach to a revision. This still runs lint '. | 'which you may later attach to a revision.'), | ||||
'unit tests. See also %s.', | |||||
'--only'), | |||||
'conflicts' => array( | 'conflicts' => array( | ||||
'only' => null, | 'edit' => pht('%s does affect revisions.', '--only'), | ||||
'edit' => pht('%s does affect revisions.', '--preview'), | 'message' => pht('%s does not update any revision.', '--only'), | ||||
'message' => pht('%s does not update any revision.', '--preview'), | |||||
), | |||||
), | |||||
'plan-changes' => array( | |||||
'help' => pht( | |||||
'Create or update a revision without requesting a code review.'), | |||||
'conflicts' => array( | |||||
'only' => pht('%s does not affect revisions.', '--only'), | |||||
'preview' => pht('%s does not affect revisions.', '--preview'), | |||||
), | ), | ||||
), | ), | ||||
'encoding' => array( | 'encoding' => array( | ||||
'param' => 'encoding', | 'param' => 'encoding', | ||||
'help' => pht( | 'help' => pht( | ||||
'Attempt to convert non UTF-8 hunks into specified encoding.'), | 'Attempt to convert non UTF-8 hunks into specified encoding.'), | ||||
), | ), | ||||
'allow-untracked' => array( | 'allow-untracked' => array( | ||||
▲ Show 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | $arguments = array( | ||||
'revision, update some fields from the local commit message.'), | 'revision, update some fields from the local commit message.'), | ||||
'supports' => array( | 'supports' => array( | ||||
'hg', | 'hg', | ||||
'git', | 'git', | ||||
), | ), | ||||
'conflicts' => array( | 'conflicts' => array( | ||||
'use-commit-message' => true, | 'use-commit-message' => true, | ||||
'update' => true, | 'update' => true, | ||||
'only' => true, | 'only' => true, | ||||
'preview' => true, | |||||
'raw' => true, | 'raw' => true, | ||||
'raw-command' => true, | 'raw-command' => true, | ||||
'message-file' => true, | 'message-file' => true, | ||||
), | ), | ||||
), | ), | ||||
'reviewers' => array( | 'reviewers' => array( | ||||
'param' => 'usernames', | 'param' => 'usernames', | ||||
'help' => pht('When creating a revision, add reviewers.'), | 'help' => pht('When creating a revision, add reviewers.'), | ||||
'conflicts' => array( | 'conflicts' => array( | ||||
'only' => true, | 'only' => true, | ||||
'preview' => true, | |||||
'update' => true, | 'update' => true, | ||||
), | ), | ||||
), | ), | ||||
'cc' => array( | 'cc' => array( | ||||
'param' => 'usernames', | 'param' => 'usernames', | ||||
'help' => pht('When creating a revision, add CCs.'), | 'help' => pht('When creating a revision, add CCs.'), | ||||
'conflicts' => array( | 'conflicts' => array( | ||||
'only' => true, | 'only' => true, | ||||
'preview' => true, | |||||
'update' => true, | 'update' => true, | ||||
), | ), | ||||
), | ), | ||||
'skip-binaries' => array( | 'skip-binaries' => array( | ||||
'help' => pht('Do not upload binaries (like images).'), | 'help' => pht('Do not upload binaries (like images).'), | ||||
), | ), | ||||
'skip-staging' => array( | 'skip-staging' => array( | ||||
'help' => pht('Do not copy changes to the staging area.'), | 'help' => pht('Do not copy changes to the staging area.'), | ||||
), | ), | ||||
'ignore-unsound-tests' => array( | 'ignore-unsound-tests' => array( | ||||
'help' => pht('Ignore unsound test failures without prompting.'), | 'help' => pht('Ignore unsound test failures without prompting.'), | ||||
), | ), | ||||
'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'), | ||||
), | ), | ||||
'no-diff' => array( | |||||
'help' => pht( | |||||
'Only run lint and unit tests. Intended for internal use.'), | |||||
), | |||||
'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 All 33 Lines | EOTEXT | ||||
public function isRawDiffSource() { | public function isRawDiffSource() { | ||||
return $this->getArgument('raw') || $this->getArgument('raw-command'); | return $this->getArgument('raw') || $this->getArgument('raw-command'); | ||||
} | } | ||||
public function run() { | public function run() { | ||||
$this->console = PhutilConsole::getConsole(); | $this->console = PhutilConsole::getConsole(); | ||||
$this->runRepositoryAPISetup(); | $this->runRepositoryAPISetup(); | ||||
if ($this->getArgument('no-diff')) { | |||||
$this->removeScratchFile('diff-result.json'); | |||||
$data = $this->runLintUnit(); | |||||
$this->writeScratchJSONFile('diff-result.json', $data); | |||||
return 0; | |||||
} | |||||
$this->runDiffSetupBasics(); | $this->runDiffSetupBasics(); | ||||
$commit_message = $this->buildCommitMessage(); | $commit_message = $this->buildCommitMessage(); | ||||
$this->dispatchEvent( | $this->dispatchEvent( | ||||
ArcanistEventType::TYPE_DIFF_DIDBUILDMESSAGE, | ArcanistEventType::TYPE_DIFF_DIDBUILDMESSAGE, | ||||
array( | array( | ||||
'message' => $commit_message, | 'message' => $commit_message, | ||||
▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | if ($this->shouldOnlyCreateDiff()) { | ||||
))."\n"; | ))."\n"; | ||||
ob_start(); | ob_start(); | ||||
} | } | ||||
if ($this->shouldOpenCreatedObjectsInBrowser()) { | if ($this->shouldOpenCreatedObjectsInBrowser()) { | ||||
$this->openURIsInBrowser(array($diff_info['uri'])); | $this->openURIsInBrowser(array($diff_info['uri'])); | ||||
} | } | ||||
} else { | } else { | ||||
$is_draft = $this->getArgument('draft'); | |||||
$revision['diffid'] = $this->getDiffID(); | $revision['diffid'] = $this->getDiffID(); | ||||
if ($commit_message->getRevisionID()) { | if ($commit_message->getRevisionID()) { | ||||
if ($is_draft) { | |||||
// TODO: In at least some cases, we could raise this earlier in the | |||||
// workflow to save users some time before the workflow aborts. | |||||
if ($this->revisionIsDraft) { | |||||
$this->writeWarn( | |||||
pht('ALREADY A DRAFT'), | |||||
pht( | |||||
'You are updating a revision ("%s") with the "--draft" flag, '. | |||||
'but this revision is already a draft. You only need to '. | |||||
'provide the "--draft" flag when creating a revision. Draft '. | |||||
'revisions are not published until you explicitly request '. | |||||
'review from the web UI.', | |||||
$commit_message->getRevisionMonogram())); | |||||
} else { | |||||
throw new ArcanistUsageException( | |||||
pht( | |||||
'You are updating a revision ("%s") with the "--draft" flag, '. | |||||
'but this revision has already been published for review. '. | |||||
'You can not turn a revision back into a draft once it has '. | |||||
'been published.', | |||||
$commit_message->getRevisionMonogram())); | |||||
} | |||||
} | |||||
$result = $conduit->callMethodSynchronous( | $result = $conduit->callMethodSynchronous( | ||||
'differential.updaterevision', | 'differential.updaterevision', | ||||
$revision); | $revision); | ||||
foreach (array('edit-messages.json', 'update-messages.json') as $file) { | foreach (array('edit-messages.json', 'update-messages.json') as $file) { | ||||
$messages = $this->readScratchJSONFile($file); | $messages = $this->readScratchJSONFile($file); | ||||
unset($messages[$revision['id']]); | unset($messages[$revision['id']]); | ||||
$this->writeScratchJSONFile($file, $messages); | $this->writeScratchJSONFile($file, $messages); | ||||
} | } | ||||
$result_uri = $result['uri']; | |||||
$result_id = $result['revisionid']; | |||||
echo pht('Updated an existing Differential revision:')."\n"; | echo pht('Updated an existing Differential revision:')."\n"; | ||||
} else { | } else { | ||||
// NOTE: We're either using "differential.revision.edit" (preferred) | |||||
// if we can, or falling back to "differential.createrevision" | |||||
// (the older way) if not. | |||||
$xactions = $this->revisionTransactions; | |||||
if ($xactions) { | |||||
$xactions[] = array( | |||||
'type' => 'update', | |||||
'value' => $diff_info['phid'], | |||||
); | |||||
if ($is_draft) { | |||||
$xactions[] = array( | |||||
'type' => 'draft', | |||||
'value' => true, | |||||
); | |||||
} | |||||
$result = $conduit->callMethodSynchronous( | |||||
'differential.revision.edit', | |||||
array( | |||||
'transactions' => $xactions, | |||||
)); | |||||
$result_id = idxv($result, array('object', 'id')); | |||||
if (!$result_id) { | |||||
throw new Exception( | |||||
pht( | |||||
'Expected a revision ID to be returned by '. | |||||
'"differential.revision.edit".')); | |||||
} | |||||
// TODO: This is hacky, but we don't currently receive a URI back | |||||
// from "differential.revision.edit". | |||||
$result_uri = id(new PhutilURI($this->getConduitURI())) | |||||
->setPath('/D'.$result_id); | |||||
} else { | |||||
if ($is_draft) { | |||||
throw new ArcanistUsageException( | |||||
pht( | |||||
'You have specified "--draft", but the version of Phabricator '. | |||||
'on the server is too old to support draft revisions. Omit '. | |||||
'the flag or upgrade the server software.')); | |||||
} | |||||
$revision = $this->dispatchWillCreateRevisionEvent($revision); | $revision = $this->dispatchWillCreateRevisionEvent($revision); | ||||
$result = $conduit->callMethodSynchronous( | $result = $conduit->callMethodSynchronous( | ||||
'differential.createrevision', | 'differential.createrevision', | ||||
$revision); | $revision); | ||||
$result_uri = $result['uri']; | |||||
$result_id = $result['revisionid']; | |||||
} | |||||
$revised_message = $conduit->callMethodSynchronous( | $revised_message = $conduit->callMethodSynchronous( | ||||
'differential.getcommitmessage', | 'differential.getcommitmessage', | ||||
array( | array( | ||||
'revision_id' => $result['revisionid'], | 'revision_id' => $result_id, | ||||
)); | )); | ||||
if ($this->shouldAmend()) { | if ($this->shouldAmend()) { | ||||
$repository_api = $this->getRepositoryAPI(); | $repository_api = $this->getRepositoryAPI(); | ||||
if ($repository_api->supportsAmend()) { | if ($repository_api->supportsAmend()) { | ||||
echo pht('Updating commit message...')."\n"; | echo pht('Updating commit message...')."\n"; | ||||
$repository_api->amendCommit($revised_message); | $repository_api->amendCommit($revised_message); | ||||
} else { | } else { | ||||
echo pht( | echo pht( | ||||
'Commit message was not amended. Amending commit message is '. | 'Commit message was not amended. Amending commit message is '. | ||||
'only supported in git and hg (version 2.2 or newer)'); | 'only supported in git and hg (version 2.2 or newer)'); | ||||
} | } | ||||
} | } | ||||
echo pht('Created a new Differential revision:')."\n"; | echo pht('Created a new Differential revision:')."\n"; | ||||
} | } | ||||
$uri = $result['uri']; | $uri = $result_uri; | ||||
echo phutil_console_format( | echo phutil_console_format( | ||||
" **%s** __%s__\n\n", | " **%s** __%s__\n\n", | ||||
pht('Revision URI:'), | pht('Revision URI:'), | ||||
$uri); | $uri); | ||||
if ($this->getArgument('plan-changes')) { | |||||
$conduit->callMethodSynchronous( | |||||
'differential.createcomment', | |||||
array( | |||||
'revision_id' => $result['revisionid'], | |||||
'action' => 'rethink', | |||||
)); | |||||
echo pht('Planned changes to the revision.')."\n"; | |||||
} | |||||
if ($this->shouldOpenCreatedObjectsInBrowser()) { | if ($this->shouldOpenCreatedObjectsInBrowser()) { | ||||
$this->openURIsInBrowser(array($uri)); | $this->openURIsInBrowser(array($uri)); | ||||
} | } | ||||
} | } | ||||
echo pht('Included changes:')."\n"; | echo pht('Included changes:')."\n"; | ||||
foreach ($changes as $change) { | foreach ($changes as $change) { | ||||
echo ' '.$change->renderTextSummary()."\n"; | echo ' '.$change->renderTextSummary()."\n"; | ||||
▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | private function buildRevisionFromCommitMessage( | ||||
ArcanistDifferentialCommitMessage $message) { | ArcanistDifferentialCommitMessage $message) { | ||||
$conduit = $this->getConduit(); | $conduit = $this->getConduit(); | ||||
$revision_id = $message->getRevisionID(); | $revision_id = $message->getRevisionID(); | ||||
$revision = array( | $revision = array( | ||||
'fields' => $message->getFields(), | 'fields' => $message->getFields(), | ||||
); | ); | ||||
$xactions = $message->getTransactions(); | |||||
if ($revision_id) { | if ($revision_id) { | ||||
// With '--verbatim', pass the (possibly modified) local fields. This | // With '--verbatim', pass the (possibly modified) local fields. This | ||||
// allows the user to edit some fields (like "title" and "summary") | // allows the user to edit some fields (like "title" and "summary") | ||||
// locally without '--edit' and have changes automatically synchronized. | // locally without '--edit' and have changes automatically synchronized. | ||||
// Without '--verbatim', we do not update the revision to reflect local | // Without '--verbatim', we do not update the revision to reflect local | ||||
// commit message changes. | // commit message changes. | ||||
Show All 38 Lines | if ($revision_id) { | ||||
$remote_corpus = ArcanistCommentRemover::removeComments( | $remote_corpus = ArcanistCommentRemover::removeComments( | ||||
$remote_corpus); | $remote_corpus); | ||||
$new_message = ArcanistDifferentialCommitMessage::newFromRawCorpus( | $new_message = ArcanistDifferentialCommitMessage::newFromRawCorpus( | ||||
$remote_corpus); | $remote_corpus); | ||||
$new_message->pullDataFromConduit($conduit); | $new_message->pullDataFromConduit($conduit); | ||||
} | } | ||||
$revision['fields'] = $new_message->getFields(); | $revision['fields'] = $new_message->getFields(); | ||||
$xactions = $new_message->getTransactions(); | |||||
$revision['id'] = $revision_id; | $revision['id'] = $revision_id; | ||||
$this->revisionID = $revision_id; | $this->revisionID = $revision_id; | ||||
$revision['message'] = $this->getArgument('message'); | $revision['message'] = $this->getArgument('message'); | ||||
if (!strlen($revision['message'])) { | if (!strlen($revision['message'])) { | ||||
$update_messages = $this->readScratchJSONFile('update-messages.json'); | $update_messages = $this->readScratchJSONFile('update-messages.json'); | ||||
$update_messages[$revision_id] = $this->getUpdateMessage( | $update_messages[$revision_id] = $this->getUpdateMessage( | ||||
$revision['fields'], | $revision['fields'], | ||||
idx($update_messages, $revision_id)); | idx($update_messages, $revision_id)); | ||||
$revision['message'] = ArcanistCommentRemover::removeComments( | $revision['message'] = ArcanistCommentRemover::removeComments( | ||||
$update_messages[$revision_id]); | $update_messages[$revision_id]); | ||||
if (!strlen(trim($revision['message']))) { | if (!strlen(trim($revision['message']))) { | ||||
throw new ArcanistUserAbortException(); | throw new ArcanistUserAbortException(); | ||||
} | } | ||||
$this->writeScratchJSONFile('update-messages.json', $update_messages); | $this->writeScratchJSONFile('update-messages.json', $update_messages); | ||||
} | } | ||||
} | } | ||||
$this->revisionTransactions = $xactions; | |||||
return $revision; | return $revision; | ||||
} | } | ||||
protected function shouldOnlyCreateDiff() { | protected function shouldOnlyCreateDiff() { | ||||
if ($this->getArgument('create')) { | if ($this->getArgument('create')) { | ||||
return false; | return false; | ||||
} | } | ||||
if ($this->getArgument('update')) { | if ($this->getArgument('update')) { | ||||
return false; | return false; | ||||
} | } | ||||
if ($this->getArgument('use-commit-message')) { | if ($this->getArgument('use-commit-message')) { | ||||
return false; | return false; | ||||
} | } | ||||
if ($this->isRawDiffSource()) { | if ($this->isRawDiffSource()) { | ||||
return true; | return true; | ||||
} | } | ||||
return $this->getArgument('preview') || | return $this->getArgument('only'); | ||||
$this->getArgument('only'); | |||||
} | } | ||||
private function generateAffectedPaths() { | private function generateAffectedPaths() { | ||||
if ($this->isRawDiffSource()) { | if ($this->isRawDiffSource()) { | ||||
return array(); | return array(); | ||||
} | } | ||||
$repository_api = $this->getRepositoryAPI(); | $repository_api = $this->getRepositoryAPI(); | ||||
▲ Show 20 Lines • Show All 404 Lines • ▼ Show 20 Lines | /* -( Lint and Unit Tests )------------------------------------------------ */ | ||||
} | } | ||||
/** | /** | ||||
* @task lintunit | * @task lintunit | ||||
*/ | */ | ||||
private function runLint() { | private function runLint() { | ||||
if ($this->getArgument('nolint') || | if ($this->getArgument('nolint') || | ||||
$this->getArgument('only') || | |||||
$this->isRawDiffSource() || | $this->isRawDiffSource() || | ||||
$this->getArgument('head')) { | $this->getArgument('head')) { | ||||
return ArcanistLintWorkflow::RESULT_SKIP; | return ArcanistLintWorkflow::RESULT_SKIP; | ||||
} | } | ||||
$repository_api = $this->getRepositoryAPI(); | $repository_api = $this->getRepositoryAPI(); | ||||
$this->console->writeOut("%s\n", pht('Linting...')); | $this->console->writeOut("%s\n", pht('Linting...')); | ||||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | /* -( Lint and Unit Tests )------------------------------------------------ */ | ||||
} | } | ||||
/** | /** | ||||
* @task lintunit | * @task lintunit | ||||
*/ | */ | ||||
private function runUnit() { | private function runUnit() { | ||||
if ($this->getArgument('nounit') || | if ($this->getArgument('nounit') || | ||||
$this->getArgument('only') || | |||||
$this->isRawDiffSource() || | $this->isRawDiffSource() || | ||||
$this->getArgument('head')) { | $this->getArgument('head')) { | ||||
return ArcanistUnitWorkflow::RESULT_SKIP; | return ArcanistUnitWorkflow::RESULT_SKIP; | ||||
} | } | ||||
$repository_api = $this->getRepositoryAPI(); | $repository_api = $this->getRepositoryAPI(); | ||||
$this->console->writeOut("%s\n", pht('Running unit tests...')); | $this->console->writeOut("%s\n", pht('Running unit tests...')); | ||||
▲ Show 20 Lines • Show All 127 Lines • ▼ Show 20 Lines | |||||
/* -( Commit and Update Messages )----------------------------------------- */ | /* -( Commit and Update Messages )----------------------------------------- */ | ||||
/** | /** | ||||
* @task message | * @task message | ||||
*/ | */ | ||||
private function buildCommitMessage() { | private function buildCommitMessage() { | ||||
if ($this->getArgument('preview') || $this->getArgument('only')) { | if ($this->getArgument('only')) { | ||||
return null; | return null; | ||||
} | } | ||||
$is_create = $this->getArgument('create'); | $is_create = $this->getArgument('create'); | ||||
$is_update = $this->getArgument('update'); | $is_update = $this->getArgument('update'); | ||||
$is_raw = $this->isRawDiffSource(); | $is_raw = $this->isRawDiffSource(); | ||||
$is_message = $this->getArgument('use-commit-message'); | $is_message = $this->getArgument('use-commit-message'); | ||||
$is_verbatim = $this->getArgument('verbatim'); | $is_verbatim = $this->getArgument('verbatim'); | ||||
▲ Show 20 Lines • Show All 301 Lines • ▼ Show 20 Lines | if (!$revision) { | ||||
throw new ArcanistUsageException( | throw new ArcanistUsageException( | ||||
pht( | pht( | ||||
"Revision '%s' does not exist!", | "Revision '%s' does not exist!", | ||||
$revision_id)); | $revision_id)); | ||||
} | } | ||||
$this->checkRevisionOwnership($revision); | $this->checkRevisionOwnership($revision); | ||||
// TODO: Save this status to improve a prompt later. See PHI458. This is | |||||
// extra awful until we move to "differential.revision.search" because | |||||
// the "differential.query" method doesn't return a real draft status for | |||||
// compatibility. | |||||
$this->revisionIsDraft = (idx($revision, 'statusName') === 'Draft'); | |||||
$message = $this->getConduit()->callMethodSynchronous( | $message = $this->getConduit()->callMethodSynchronous( | ||||
'differential.getcommitmessage', | 'differential.getcommitmessage', | ||||
array( | array( | ||||
'revision_id' => $id, | 'revision_id' => $id, | ||||
'edit' => false, | 'edit' => false, | ||||
)); | )); | ||||
$this->commitMessageFromRevision = $message; | $this->commitMessageFromRevision = $message; | ||||
▲ Show 20 Lines • Show All 1,224 Lines • Show Last 20 Lines |