mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 00:42:41 +01:00
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:
parent
9b318e4044
commit
6f4665756d
2 changed files with 18 additions and 12 deletions
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (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(
|
||||
'revision_id' => 'optional revision_id',
|
||||
'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();
|
||||
|
||||
$is_edit = $request->getValue('edit');
|
||||
$is_create = ($is_edit == 'create');
|
||||
|
||||
$aux_fields = DifferentialFieldSelector::newSelector()
|
||||
->getFieldSpecifications();
|
||||
|
@ -88,7 +89,8 @@ class ConduitAPI_differential_getcommitmessage_Method extends ConduitAPIMethod {
|
|||
"correspond to any configured field.");
|
||||
}
|
||||
|
||||
if ($aux_field->shouldOverwriteWhenCommitMessageIsEdited()) {
|
||||
if ($is_create ||
|
||||
$aux_field->shouldOverwriteWhenCommitMessageIsEdited()) {
|
||||
$aux_field->setValueFromParsedCommitMessage($value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,8 @@ class ConduitAPI_differential_parsecommitmessage_Method
|
|||
|
||||
public function defineParamTypes() {
|
||||
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) {
|
||||
$corpus = $request->getValue('corpus');
|
||||
$is_partial = $request->getValue('partial');
|
||||
|
||||
$aux_fields = DifferentialFieldSelector::newSelector()
|
||||
->getFieldSpecifications();
|
||||
|
@ -74,14 +76,16 @@ class ConduitAPI_differential_parsecommitmessage_Method
|
|||
}
|
||||
}
|
||||
|
||||
foreach ($aux_fields as $field_key => $aux_field) {
|
||||
try {
|
||||
$aux_field->validateField();
|
||||
} catch (DifferentialFieldValidationException $ex) {
|
||||
$field_label = $aux_field->renderLabelForCommitMessage();
|
||||
$errors[] =
|
||||
"Invalid or missing field '{$field_label}': ".
|
||||
$ex->getMessage();
|
||||
if (!$is_partial) {
|
||||
foreach ($aux_fields as $field_key => $aux_field) {
|
||||
try {
|
||||
$aux_field->validateField();
|
||||
} catch (DifferentialFieldValidationException $ex) {
|
||||
$field_label = $aux_field->renderLabelForCommitMessage();
|
||||
$errors[] =
|
||||
"Invalid or missing field '{$field_label}': ".
|
||||
$ex->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue