Changeset View
Changeset View
Standalone View
Standalone View
src/workflow/ArcanistDiffWorkflow.php
Show First 20 Lines • Show All 695 Lines • ▼ Show 20 Lines | if ($revision_id) { | ||||
$revision['fields'] = $new_message->getFields(); | $revision['fields'] = $new_message->getFields(); | ||||
$xactions = $new_message->getTransactions(); | $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 ($revision['message'] === null) { | ||||
$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]); | ||||
▲ Show 20 Lines • Show All 1,022 Lines • ▼ Show 20 Lines | private function getUpdateMessage(array $fields, $template = '') { | ||||
// $ arc diff | // $ arc diff | ||||
// | // | ||||
// ...you shouldn't have to retype the update message. Similar things apply | // ...you shouldn't have to retype the update message. Similar things apply | ||||
// to Mercurial. | // to Mercurial. | ||||
if ($template == '') { | if ($template == '') { | ||||
$comments = $this->getDefaultUpdateMessage(); | $comments = $this->getDefaultUpdateMessage(); | ||||
$comments = phutil_string_cast($comments); | |||||
$comments = rtrim($comments); | |||||
$template = sprintf( | $template = sprintf( | ||||
"%s\n\n# %s\n#\n# %s\n# %s\n#\n# %s\n# $ %s\n\n", | "%s\n\n# %s\n#\n# %s\n# %s\n#\n# %s\n# $ %s\n\n", | ||||
rtrim($comments), | $comments, | ||||
pht( | pht( | ||||
'Updating %s: %s', | 'Updating %s: %s', | ||||
"D{$fields['revisionID']}", | "D{$fields['revisionID']}", | ||||
$fields['title']), | $fields['title']), | ||||
pht( | pht( | ||||
'Enter a brief description of the changes included in this update.'), | 'Enter a brief description of the changes included in this update.'), | ||||
pht('The first line is used as subject, next lines as comment.'), | pht('The first line is used as subject, next lines as comment.'), | ||||
pht('If you intended to create a new revision, use:'), | pht('If you intended to create a new revision, use:'), | ||||
▲ Show 20 Lines • Show All 601 Lines • ▼ Show 20 Lines | if (!($api instanceof ArcanistGitAPI)) { | ||||
return null; | return null; | ||||
} | } | ||||
// If we track an upstream branch either directly or indirectly, use that. | // If we track an upstream branch either directly or indirectly, use that. | ||||
$branch = $api->getBranchName(); | $branch = $api->getBranchName(); | ||||
if (strlen($branch)) { | if (strlen($branch)) { | ||||
$upstream_path = $api->getPathToUpstream($branch); | $upstream_path = $api->getPathToUpstream($branch); | ||||
$remote_branch = $upstream_path->getRemoteBranchName(); | $remote_branch = $upstream_path->getRemoteBranchName(); | ||||
if (strlen($remote_branch)) { | if ($remote_branch !== null) { | ||||
return array( | return array( | ||||
array( | array( | ||||
'type' => 'branch', | 'type' => 'branch', | ||||
'name' => $remote_branch, | 'name' => $remote_branch, | ||||
'kind' => 'upstream', | 'kind' => 'upstream', | ||||
), | ), | ||||
); | ); | ||||
} | } | ||||
} | } | ||||
// If "arc.land.onto.default" is configured, use that. | // If "arc.land.onto.default" is configured, use that. | ||||
$config_key = 'arc.land.onto.default'; | $config_key = 'arc.land.onto.default'; | ||||
$onto = $this->getConfigFromAnySource($config_key); | $onto = $this->getConfigFromAnySource($config_key); | ||||
if (strlen($onto)) { | if ($onto !== null) { | ||||
return array( | return array( | ||||
array( | array( | ||||
'type' => 'branch', | 'type' => 'branch', | ||||
'name' => $onto, | 'name' => $onto, | ||||
'kind' => 'arc.land.onto.default', | 'kind' => 'arc.land.onto.default', | ||||
), | ), | ||||
); | ); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 511 Lines • Show Last 20 Lines |