Changeset View
Changeset View
Standalone View
Standalone View
src/workflow/ArcanistDiffWorkflow.php
Show First 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | public function requiresAuthentication() { | ||||
return true; | return true; | ||||
} | } | ||||
public function requiresRepositoryAPI() { | public function requiresRepositoryAPI() { | ||||
if (!$this->isRawDiffSource()) { | if (!$this->isRawDiffSource()) { | ||||
return true; | return true; | ||||
} | } | ||||
if ($this->getArgument('use-commit-message')) { | |||||
return true; | |||||
} | |||||
return false; | return false; | ||||
} | } | ||||
public function getDiffID() { | public function getDiffID() { | ||||
return $this->diffID; | return $this->diffID; | ||||
} | } | ||||
public function getArguments() { | public function getArguments() { | ||||
$arguments = array( | $arguments = array( | ||||
'message' => array( | 'message' => array( | ||||
'short' => 'm', | 'short' => 'm', | ||||
'param' => 'message', | 'param' => 'message', | ||||
'help' => pht( | 'help' => pht( | ||||
'When updating a revision, use the specified message instead of '. | 'When updating a revision, use the specified message instead of '. | ||||
'prompting.'), | 'prompting.'), | ||||
), | ), | ||||
'message-file' => array( | 'message-file' => array( | ||||
'short' => 'F', | 'short' => 'F', | ||||
'param' => 'file', | 'param' => 'file', | ||||
'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( | |||||
'supports' => array( | |||||
'git', | |||||
// TODO: Support mercurial. | |||||
), | |||||
'short' => 'C', | |||||
'param' => 'commit', | |||||
'help' => pht('Read revision information from a specific commit.'), | |||||
'conflicts' => array( | |||||
'only' => null, | |||||
'update' => null, | |||||
), | |||||
), | |||||
'edit' => array( | 'edit' => array( | ||||
'supports' => array( | 'supports' => array( | ||||
'git', | 'git', | ||||
'hg', | 'hg', | ||||
), | ), | ||||
'nosupport' => array( | 'nosupport' => array( | ||||
'svn' => pht('Edit revisions via the web interface when using SVN.'), | 'svn' => pht('Edit revisions via the web interface when using SVN.'), | ||||
), | ), | ||||
▲ Show 20 Lines • Show All 197 Lines • ▼ Show 20 Lines | $arguments = array( | ||||
'When creating a revision, try to use the working copy commit '. | 'When creating a revision, try to use the working copy commit '. | ||||
'message verbatim, without prompting to edit it. When updating a '. | 'message verbatim, without prompting to edit it. When updating a '. | ||||
'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, | |||||
'update' => true, | 'update' => true, | ||||
'only' => true, | 'only' => true, | ||||
'raw' => true, | 'raw' => true, | ||||
'raw-command' => true, | 'raw-command' => true, | ||||
'message-file' => true, | 'message-file' => true, | ||||
), | ), | ||||
), | ), | ||||
'reviewers' => array( | 'reviewers' => array( | ||||
▲ Show 20 Lines • Show All 474 Lines • ▼ Show 20 Lines | 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')) { | |||||
return false; | |||||
} | |||||
if ($this->isRawDiffSource()) { | if ($this->isRawDiffSource()) { | ||||
return true; | return true; | ||||
} | } | ||||
return $this->getArgument('only'); | return $this->getArgument('only'); | ||||
} | } | ||||
private function generateAffectedPaths() { | private function generateAffectedPaths() { | ||||
▲ Show 20 Lines • Show All 639 Lines • ▼ Show 20 Lines | /* -( Commit and Update Messages )----------------------------------------- */ | ||||
private function buildCommitMessage() { | private function buildCommitMessage() { | ||||
if ($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_verbatim = $this->getArgument('verbatim'); | $is_verbatim = $this->getArgument('verbatim'); | ||||
if ($is_message) { | |||||
return $this->getCommitMessageFromCommit($is_message); | |||||
} | |||||
if ($is_verbatim) { | if ($is_verbatim) { | ||||
return $this->getCommitMessageFromUser(); | return $this->getCommitMessageFromUser(); | ||||
} | } | ||||
if (!$is_raw && !$is_create && !$is_update) { | if (!$is_raw && !$is_create && !$is_update) { | ||||
$repository_api = $this->getRepositoryAPI(); | $repository_api = $this->getRepositoryAPI(); | ||||
$revisions = $repository_api->loadWorkingCopyDifferentialRevisions( | $revisions = $repository_api->loadWorkingCopyDifferentialRevisions( | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | if ($is_create) { | ||||
return null; | return null; | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* @task message | * @task message | ||||
*/ | */ | ||||
private function getCommitMessageFromCommit($commit) { | |||||
$text = $this->getRepositoryAPI()->getCommitMessage($commit); | |||||
$message = ArcanistDifferentialCommitMessage::newFromRawCorpus($text); | |||||
$message->pullDataFromConduit($this->getConduit()); | |||||
$this->validateCommitMessage($message); | |||||
return $message; | |||||
} | |||||
/** | |||||
* @task message | |||||
*/ | |||||
private function getCommitMessageFromUser() { | private function getCommitMessageFromUser() { | ||||
$conduit = $this->getConduit(); | $conduit = $this->getConduit(); | ||||
$template = null; | $template = null; | ||||
if (!$this->getArgument('verbatim')) { | if (!$this->getArgument('verbatim')) { | ||||
$saved = $this->readScratchFile('create-message'); | $saved = $this->readScratchFile('create-message'); | ||||
if ($saved) { | if ($saved) { | ||||
▲ Show 20 Lines • Show All 1,527 Lines • Show Last 20 Lines |