public function testDifferentialCommitMessageParserNormalization()
 {
     $map = array('Test Plan' => 'test plan', 'REVIEWERS' => 'reviewers', 'sUmmArY' => 'summary');
     foreach ($map as $input => $expect) {
         $this->assertEqual($expect, DifferentialCommitMessageParser::normalizeFieldLabel($input), pht('Field normalization of label "%s".', $input));
     }
 }
 private function parseCommitMessage($corpus)
 {
     $viewer = $this->getViewer();
     $parser = DifferentialCommitMessageParser::newStandardParser($viewer);
     $result = $parser->parseCorpus($corpus);
     $this->errors = array();
     foreach ($parser->getErrors() as $error) {
         $this->errors[] = $error;
     }
     return $result;
 }
 private function getFieldParser()
 {
     if (!$this->fieldParser) {
         $viewer = $this->getViewer();
         $parser = DifferentialCommitMessageParser::newStandardParser($viewer);
         // Set custom title and summary keys so we can detect the presence of
         // "Summary:" in, e.g., a test plan.
         $parser->setTitleKey('__title__');
         $parser->setSummaryKey('__summary__');
         $this->fieldParser = $parser;
     }
     return $this->fieldParser;
 }
 private function buildLabelMap(PhabricatorCustomFieldList $field_list)
 {
     $label_map = array();
     foreach ($field_list->getFields() as $key => $field) {
         $labels = $field->getCommitMessageLabels();
         $key = $field->getFieldKeyForConduit();
         foreach ($labels as $label) {
             $normal_label = DifferentialCommitMessageParser::normalizeFieldLabel($label);
             if (!empty($label_map[$normal_label])) {
                 throw new Exception(pht('Field label "%s" is parsed by two custom fields: "%s" and ' . '"%s". Each label must be parsed by only one field.', $label, $key, $label_map[$normal_label]));
             }
             $label_map[$normal_label] = $key;
         }
     }
     return $label_map;
 }