Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/differential/conduit/DifferentialParseCommitMessageConduitAPIMethod.php
12256 views
1
<?php
2
3
final class DifferentialParseCommitMessageConduitAPIMethod
4
extends DifferentialConduitAPIMethod {
5
6
public function getAPIMethodName() {
7
return 'differential.parsecommitmessage';
8
}
9
10
public function getMethodDescription() {
11
return pht('Parse commit messages for Differential fields.');
12
}
13
14
protected function defineParamTypes() {
15
return array(
16
'corpus' => 'required string',
17
'partial' => 'optional bool',
18
);
19
}
20
21
protected function defineReturnType() {
22
return 'nonempty dict';
23
}
24
25
protected function execute(ConduitAPIRequest $request) {
26
$viewer = $this->getViewer();
27
28
$parser = DifferentialCommitMessageParser::newStandardParser($viewer);
29
30
$is_partial = $request->getValue('partial');
31
if ($is_partial) {
32
$parser->setRaiseMissingFieldErrors(false);
33
}
34
35
$corpus = $request->getValue('corpus');
36
if ($corpus === null || !strlen($corpus)) {
37
throw new Exception(pht('Field "corpus" must be non-empty.'));
38
}
39
$field_map = $parser->parseFields($corpus);
40
41
$errors = $parser->getErrors();
42
$xactions = $parser->getTransactions();
43
44
$revision_id_value = idx(
45
$field_map,
46
DifferentialRevisionIDCommitMessageField::FIELDKEY);
47
$revision_id_valid_domain = PhabricatorEnv::getProductionURI('');
48
49
return array(
50
'errors' => $errors,
51
'fields' => $field_map,
52
'revisionIDFieldInfo' => array(
53
'value' => $revision_id_value,
54
'validDomain' => $revision_id_valid_domain,
55
),
56
'transactions' => $xactions,
57
);
58
}
59
60
}
61
62