Make Conduit parsers more flexible for 'arc diff --create'
Summary: Adds softer parse modes with less validation for doing partial parses during the "arc diff --create" flow. Test Plan: Ran "arc diff --create" and got sensible results for inputs like bad reviewers but a good title/summary. Reviewers: btrahan Reviewed By: btrahan CC: aran, epriestley Maniphest Tasks: T614 Differential Revision: https://secure.phabricator.com/D1720
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2011 Facebook, Inc.
|
* Copyright 2012 Facebook, Inc.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -29,7 +29,7 @@ class ConduitAPI_differential_getcommitmessage_Method extends ConduitAPIMethod {
|
|||||||
return array(
|
return array(
|
||||||
'revision_id' => 'optional revision_id',
|
'revision_id' => 'optional revision_id',
|
||||||
'fields' => 'optional dict<string, wild>',
|
'fields' => 'optional dict<string, wild>',
|
||||||
'edit' => 'optional bool',
|
'edit' => 'optional enum<"edit", "create">',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,6 +58,7 @@ class ConduitAPI_differential_getcommitmessage_Method extends ConduitAPIMethod {
|
|||||||
$revision->loadRelationships();
|
$revision->loadRelationships();
|
||||||
|
|
||||||
$is_edit = $request->getValue('edit');
|
$is_edit = $request->getValue('edit');
|
||||||
|
$is_create = ($is_edit == 'create');
|
||||||
|
|
||||||
$aux_fields = DifferentialFieldSelector::newSelector()
|
$aux_fields = DifferentialFieldSelector::newSelector()
|
||||||
->getFieldSpecifications();
|
->getFieldSpecifications();
|
||||||
@@ -88,7 +89,8 @@ class ConduitAPI_differential_getcommitmessage_Method extends ConduitAPIMethod {
|
|||||||
"correspond to any configured field.");
|
"correspond to any configured field.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($aux_field->shouldOverwriteWhenCommitMessageIsEdited()) {
|
if ($is_create ||
|
||||||
|
$aux_field->shouldOverwriteWhenCommitMessageIsEdited()) {
|
||||||
$aux_field->setValueFromParsedCommitMessage($value);
|
$aux_field->setValueFromParsedCommitMessage($value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ class ConduitAPI_differential_parsecommitmessage_Method
|
|||||||
|
|
||||||
public function defineParamTypes() {
|
public function defineParamTypes() {
|
||||||
return array(
|
return array(
|
||||||
'corpus' => 'required string',
|
'corpus' => 'required string',
|
||||||
|
'partial' => 'optional bool',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,6 +44,7 @@ class ConduitAPI_differential_parsecommitmessage_Method
|
|||||||
|
|
||||||
protected function execute(ConduitAPIRequest $request) {
|
protected function execute(ConduitAPIRequest $request) {
|
||||||
$corpus = $request->getValue('corpus');
|
$corpus = $request->getValue('corpus');
|
||||||
|
$is_partial = $request->getValue('partial');
|
||||||
|
|
||||||
$aux_fields = DifferentialFieldSelector::newSelector()
|
$aux_fields = DifferentialFieldSelector::newSelector()
|
||||||
->getFieldSpecifications();
|
->getFieldSpecifications();
|
||||||
@@ -74,14 +76,16 @@ class ConduitAPI_differential_parsecommitmessage_Method
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($aux_fields as $field_key => $aux_field) {
|
if (!$is_partial) {
|
||||||
try {
|
foreach ($aux_fields as $field_key => $aux_field) {
|
||||||
$aux_field->validateField();
|
try {
|
||||||
} catch (DifferentialFieldValidationException $ex) {
|
$aux_field->validateField();
|
||||||
$field_label = $aux_field->renderLabelForCommitMessage();
|
} catch (DifferentialFieldValidationException $ex) {
|
||||||
$errors[] =
|
$field_label = $aux_field->renderLabelForCommitMessage();
|
||||||
"Invalid or missing field '{$field_label}': ".
|
$errors[] =
|
||||||
$ex->getMessage();
|
"Invalid or missing field '{$field_label}': ".
|
||||||
|
$ex->getMessage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user