@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Don't fatal on duplicate field in commit message

Summary:
If the actual commit message has a duplicate field and we shouldAutoclose it then the commit message parser fails.
Put the error in `$errors` instead.

Test Plan:
Reparsed commit with duplicate field in message.
Tried to `arc diff` message with duplicate field.

Reviewers: epriestley, nh

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3470

vrana d28c591e 99949bec

+9 -6
+9 -6
src/applications/conduit/method/differential/ConduitAPI_differential_parsecommitmessage_Method.php
··· 22 22 final class ConduitAPI_differential_parsecommitmessage_Method 23 23 extends ConduitAPIMethod { 24 24 25 + private $errors; 26 + 25 27 public function getMethodDescription() { 26 28 return "Parse commit messages for Differential fields."; 27 29 } ··· 58 60 59 61 $aux_fields = mpull($aux_fields, null, 'getCommitMessageKey'); 60 62 63 + $this->errors = array(); 64 + 61 65 // Build a map from labels (like "Test Plan") to field keys 62 66 // (like "testPlan"). 63 67 $label_map = $this->buildLabelMap($aux_fields); 64 68 $field_map = $this->parseCommitMessage($corpus, $label_map); 65 69 66 70 $fields = array(); 67 - $errors = array(); 68 71 foreach ($field_map as $field_key => $field_value) { 69 72 $field = $aux_fields[$field_key]; 70 73 try { ··· 72 75 $field->setValueFromParsedCommitMessage($fields[$field_key]); 73 76 } catch (DifferentialFieldParseException $ex) { 74 77 $field_label = $field->renderLabelForCommitMessage(); 75 - $errors[] = "Error parsing field '{$field_label}': ".$ex->getMessage(); 78 + $this->errors[] = 79 + "Error parsing field '{$field_label}': ".$ex->getMessage(); 76 80 } 77 81 } 78 82 ··· 82 86 $aux_field->validateField(); 83 87 } catch (DifferentialFieldValidationException $ex) { 84 88 $field_label = $aux_field->renderLabelForCommitMessage(); 85 - $errors[] = 89 + $this->errors[] = 86 90 "Invalid or missing field '{$field_label}': ". 87 91 $ex->getMessage(); 88 92 } ··· 90 94 } 91 95 92 96 return array( 93 - 'errors' => $errors, 97 + 'errors' => $this->errors, 94 98 'fields' => $fields, 95 99 ); 96 100 } ··· 144 148 $lines[$key] = trim($match['text']); 145 149 $field = $label_map[strtolower($match['field'])]; 146 150 if (!empty($seen[$field])) { 147 - throw new Exception( 148 - "Field '{$field}' occurs twice in commit message!"); 151 + $this->errors[] = "Field '{$field}' occurs twice in commit message!"; 149 152 } 150 153 $seen[$field] = true; 151 154 }