From 6f4665756dd7f5ad5e06a63f5a0c75d06b682b56 Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 28 Feb 2012 16:56:19 -0800 Subject: [PATCH] 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 --- ...I_differential_getcommitmessage_Method.php | 8 ++++--- ...differential_parsecommitmessage_Method.php | 22 +++++++++++-------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/applications/conduit/method/differential/getcommitmessage/ConduitAPI_differential_getcommitmessage_Method.php b/src/applications/conduit/method/differential/getcommitmessage/ConduitAPI_differential_getcommitmessage_Method.php index 4f3f15ae11..a1ef109a95 100644 --- a/src/applications/conduit/method/differential/getcommitmessage/ConduitAPI_differential_getcommitmessage_Method.php +++ b/src/applications/conduit/method/differential/getcommitmessage/ConduitAPI_differential_getcommitmessage_Method.php @@ -1,7 +1,7 @@ 'optional revision_id', 'fields' => 'optional dict', - '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); } } diff --git a/src/applications/conduit/method/differential/parsecommitmessage/ConduitAPI_differential_parsecommitmessage_Method.php b/src/applications/conduit/method/differential/parsecommitmessage/ConduitAPI_differential_parsecommitmessage_Method.php index 02f5ca5f12..547f1922ec 100644 --- a/src/applications/conduit/method/differential/parsecommitmessage/ConduitAPI_differential_parsecommitmessage_Method.php +++ b/src/applications/conduit/method/differential/parsecommitmessage/ConduitAPI_differential_parsecommitmessage_Method.php @@ -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(); + } } }