2011-02-06 22:42:00 +01:00
|
|
|
<?php
|
|
|
|
|
Rename Conduit classes
Summary: Ref T5655. Rename Conduit classes and provide a `getAPIMethodName` method to declare the API method.
Test Plan:
```
> echo '{}' | arc --conduit-uri='http://phabricator.joshuaspence.com' call-conduit user.whoami
Waiting for JSON parameters on stdin...
{"error":null,"errorMessage":null,"response":{"phid":"PHID-USER-lioqffnwn6y475mu5ndb","userName":"josh","realName":"Joshua Spence","image":"http:\/\/phabricator.joshuaspence.com\/res\/1404425321T\/phabricator\/3eb28cd9\/rsrc\/image\/avatar.png","uri":"http:\/\/phabricator.joshuaspence.com\/p\/josh\/","roles":["admin","verified","approved","activated"]}}
```
Reviewers: epriestley, #blessed_reviewers
Reviewed By: epriestley, #blessed_reviewers
Subscribers: epriestley, Korvin, hach-que
Maniphest Tasks: T5655
Differential Revision: https://secure.phabricator.com/D9991
2014-07-25 02:54:15 +02:00
|
|
|
final class DifferentialParseCommitMessageConduitAPIMethod
|
|
|
|
extends DifferentialConduitAPIMethod {
|
2011-02-06 22:42:00 +01:00
|
|
|
|
Rename Conduit classes
Summary: Ref T5655. Rename Conduit classes and provide a `getAPIMethodName` method to declare the API method.
Test Plan:
```
> echo '{}' | arc --conduit-uri='http://phabricator.joshuaspence.com' call-conduit user.whoami
Waiting for JSON parameters on stdin...
{"error":null,"errorMessage":null,"response":{"phid":"PHID-USER-lioqffnwn6y475mu5ndb","userName":"josh","realName":"Joshua Spence","image":"http:\/\/phabricator.joshuaspence.com\/res\/1404425321T\/phabricator\/3eb28cd9\/rsrc\/image\/avatar.png","uri":"http:\/\/phabricator.joshuaspence.com\/p\/josh\/","roles":["admin","verified","approved","activated"]}}
```
Reviewers: epriestley, #blessed_reviewers
Reviewed By: epriestley, #blessed_reviewers
Subscribers: epriestley, Korvin, hach-que
Maniphest Tasks: T5655
Differential Revision: https://secure.phabricator.com/D9991
2014-07-25 02:54:15 +02:00
|
|
|
public function getAPIMethodName() {
|
|
|
|
return 'differential.parsecommitmessage';
|
|
|
|
}
|
|
|
|
|
2011-02-06 22:42:00 +01:00
|
|
|
public function getMethodDescription() {
|
2014-06-09 20:36:49 +02:00
|
|
|
return pht('Parse commit messages for Differential fields.');
|
2011-02-06 22:42:00 +01:00
|
|
|
}
|
|
|
|
|
2015-04-13 00:59:07 +02:00
|
|
|
protected function defineParamTypes() {
|
2011-02-06 22:42:00 +01:00
|
|
|
return array(
|
2012-02-29 01:56:19 +01:00
|
|
|
'corpus' => 'required string',
|
|
|
|
'partial' => 'optional bool',
|
2011-02-06 22:42:00 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-04-13 00:59:07 +02:00
|
|
|
protected function defineReturnType() {
|
2011-02-06 22:42:00 +01:00
|
|
|
return 'nonempty dict';
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function execute(ConduitAPIRequest $request) {
|
2016-12-14 16:59:14 +01:00
|
|
|
$viewer = $this->getViewer();
|
2014-03-08 02:05:00 +01:00
|
|
|
|
2016-12-14 16:59:14 +01:00
|
|
|
$parser = DifferentialCommitMessageParser::newStandardParser($viewer);
|
Drive Differential commit message parsing through extensible fields
Summary:
I think this is the last major step -- use the fields to parse commit messages,
not a hard-coded list of stuff. This adds two primary methods to fields, one to
get all the labels they'll parse (so we can do "CC" and "CCs" and treat them as
the same field) and one to parse the string into a canonical representation
(e.g., lookup reviewers and such).
You'll need to impelement the one block of task-specific stuff I removed in
Facebook's task field:
list($pre_comment) = split(' -- ', $data);
$data = array_filter(preg_split('/[^\d]+/', $pre_comment));
foreach ($data as $k => $v) {
$data[$k] = (int)$v;
}
$data = array_unique($data);
break;
Otherwise I think this is clean.
Test Plan:
- Called the conduit method with various commit messages, parsed fields/errors
seemed correct.
- "arc diff"'d this diff onto localhost, then updated it.
- "arc amend"'d this diff.
Reviewers: jungejason, tuomaspelkonen, aran
Reviewed By: jungejason
CC: aran, jungejason, epriestley
Differential Revision: 829
2011-08-18 21:08:18 +02:00
|
|
|
|
2016-12-14 16:59:14 +01:00
|
|
|
$is_partial = $request->getValue('partial');
|
|
|
|
if ($is_partial) {
|
|
|
|
$parser->setRaiseMissingFieldErrors(false);
|
Drive Differential commit message parsing through extensible fields
Summary:
I think this is the last major step -- use the fields to parse commit messages,
not a hard-coded list of stuff. This adds two primary methods to fields, one to
get all the labels they'll parse (so we can do "CC" and "CCs" and treat them as
the same field) and one to parse the string into a canonical representation
(e.g., lookup reviewers and such).
You'll need to impelement the one block of task-specific stuff I removed in
Facebook's task field:
list($pre_comment) = split(' -- ', $data);
$data = array_filter(preg_split('/[^\d]+/', $pre_comment));
foreach ($data as $k => $v) {
$data[$k] = (int)$v;
}
$data = array_unique($data);
break;
Otherwise I think this is clean.
Test Plan:
- Called the conduit method with various commit messages, parsed fields/errors
seemed correct.
- "arc diff"'d this diff onto localhost, then updated it.
- "arc amend"'d this diff.
Reviewers: jungejason, tuomaspelkonen, aran
Reviewed By: jungejason
CC: aran, jungejason, epriestley
Differential Revision: 829
2011-08-18 21:08:18 +02:00
|
|
|
}
|
|
|
|
|
2016-12-14 16:59:14 +01:00
|
|
|
$corpus = $request->getValue('corpus');
|
|
|
|
$field_map = $parser->parseFields($corpus);
|
|
|
|
|
|
|
|
$errors = $parser->getErrors();
|
2017-10-27 19:00:34 +02:00
|
|
|
$xactions = $parser->getTransactions();
|
Validate all fields in differential.parsecommitmessage
Summary:
- We currently run ##parseValueFromCommitMessage()## on all fields present in
the message, but not ##validateField()##.
- This detects value errors (e.g., an invalid reviewer) but not higher-level
errors (e.g., a missing field).
- This can break the stacked-commits Git mutable history workflow by
recognizing too many commit messages as valid ("multiple valid commit messages,
this is ambiguous").
- This also gives you some errors ("Missing test plan") too late in "arc diff
--create" (after the diff has been built).
Test Plan:
- Grepped for validateField() calls, removed a couple of calls that had the
same implementation as the base class.
- Grepped for other calls to this to make sure I'm not stumbling into
unintended side effects, but it only runs from the diff workflow.
- Ran "arc diff --create" with an invalid test plan, got a good error early in
the process.
- Ran "arc diff master" with stacked local commits, got a correct selection of
the intended message.
Reviewers: cpiro, btrahan, jungejason
Reviewed By: cpiro
CC: aran, cpiro
Differential Revision: https://secure.phabricator.com/D1373
2012-01-12 04:55:05 +01:00
|
|
|
|
2014-10-14 01:55:26 +02:00
|
|
|
$revision_id_value = idx(
|
2016-12-14 16:59:14 +01:00
|
|
|
$field_map,
|
2016-12-16 18:14:13 +01:00
|
|
|
DifferentialRevisionIDCommitMessageField::FIELDKEY);
|
2014-10-14 01:55:26 +02:00
|
|
|
$revision_id_valid_domain = PhabricatorEnv::getProductionURI('');
|
|
|
|
|
2011-02-06 22:42:00 +01:00
|
|
|
return array(
|
2016-12-14 16:59:14 +01:00
|
|
|
'errors' => $errors,
|
|
|
|
'fields' => $field_map,
|
2014-10-14 01:55:26 +02:00
|
|
|
'revisionIDFieldInfo' => array(
|
|
|
|
'value' => $revision_id_value,
|
|
|
|
'validDomain' => $revision_id_valid_domain,
|
|
|
|
),
|
2017-10-27 19:00:34 +02:00
|
|
|
'transactions' => $xactions,
|
2011-02-06 22:42:00 +01:00
|
|
|
);
|
|
|
|
}
|
Drive Differential commit message parsing through extensible fields
Summary:
I think this is the last major step -- use the fields to parse commit messages,
not a hard-coded list of stuff. This adds two primary methods to fields, one to
get all the labels they'll parse (so we can do "CC" and "CCs" and treat them as
the same field) and one to parse the string into a canonical representation
(e.g., lookup reviewers and such).
You'll need to impelement the one block of task-specific stuff I removed in
Facebook's task field:
list($pre_comment) = split(' -- ', $data);
$data = array_filter(preg_split('/[^\d]+/', $pre_comment));
foreach ($data as $k => $v) {
$data[$k] = (int)$v;
}
$data = array_unique($data);
break;
Otherwise I think this is clean.
Test Plan:
- Called the conduit method with various commit messages, parsed fields/errors
seemed correct.
- "arc diff"'d this diff onto localhost, then updated it.
- "arc amend"'d this diff.
Reviewers: jungejason, tuomaspelkonen, aran
Reviewed By: jungejason
CC: aran, jungejason, epriestley
Differential Revision: 829
2011-08-18 21:08:18 +02:00
|
|
|
|
2011-02-06 22:42:00 +01:00
|
|
|
}
|