1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 20:10:55 +01:00
phorge-phorge/src/applications/differential/conduit/DifferentialParseCommitMessageConduitAPIMethod.php
epriestley f5336cd6e7 Return transactions from "differential.parsecommitmessage"
Summary:
Depends on D18740. Prepares `arc` to receive a `--draft` flag by letting us switch to "differential.revision.edit" instead of "differential.createrevision".

To "differential.revision.edit", we need a transaction list, but we can't automatically construct this list from a field map. Return the transaction list alongside the field map.

The next change uses this list (if available) to switch us to the modern API method.

Test Plan: Ran `arc diff` on the experiemntal branch with followup changes, got a new revision.

Reviewers: amckinley

Reviewed By: amckinley

Differential Revision: https://secure.phabricator.com/D18741
2017-10-30 15:15:42 -07:00

57 lines
1.4 KiB
PHP

<?php
final class DifferentialParseCommitMessageConduitAPIMethod
extends DifferentialConduitAPIMethod {
public function getAPIMethodName() {
return 'differential.parsecommitmessage';
}
public function getMethodDescription() {
return pht('Parse commit messages for Differential fields.');
}
protected function defineParamTypes() {
return array(
'corpus' => 'required string',
'partial' => 'optional bool',
);
}
protected function defineReturnType() {
return 'nonempty dict';
}
protected function execute(ConduitAPIRequest $request) {
$viewer = $this->getViewer();
$parser = DifferentialCommitMessageParser::newStandardParser($viewer);
$is_partial = $request->getValue('partial');
if ($is_partial) {
$parser->setRaiseMissingFieldErrors(false);
}
$corpus = $request->getValue('corpus');
$field_map = $parser->parseFields($corpus);
$errors = $parser->getErrors();
$xactions = $parser->getTransactions();
$revision_id_value = idx(
$field_map,
DifferentialRevisionIDCommitMessageField::FIELDKEY);
$revision_id_valid_domain = PhabricatorEnv::getProductionURI('');
return array(
'errors' => $errors,
'fields' => $field_map,
'revisionIDFieldInfo' => array(
'value' => $revision_id_value,
'validDomain' => $revision_id_valid_domain,
),
'transactions' => $xactions,
);
}
}