diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 62047c89da..6aa910135c 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -758,6 +758,7 @@ phutil_register_library_map(array( 'HeraldPholioMockAdapter' => 'applications/herald/adapter/HeraldPholioMockAdapter.php', 'HeraldPreCommitRefAdapter' => 'applications/diffusion/herald/HeraldPreCommitRefAdapter.php', 'HeraldRecursiveConditionsException' => 'applications/herald/engine/exception/HeraldRecursiveConditionsException.php', + 'HeraldRemarkupRule' => 'applications/herald/remarkup/HeraldRemarkupRule.php', 'HeraldRepetitionPolicyConfig' => 'applications/herald/config/HeraldRepetitionPolicyConfig.php', 'HeraldRule' => 'applications/herald/storage/HeraldRule.php', 'HeraldRuleController' => 'applications/herald/controller/HeraldRuleController.php', @@ -3181,6 +3182,7 @@ phutil_register_library_map(array( 'HeraldPholioMockAdapter' => 'HeraldAdapter', 'HeraldPreCommitRefAdapter' => 'HeraldAdapter', 'HeraldRecursiveConditionsException' => 'Exception', + 'HeraldRemarkupRule' => 'PhabricatorRemarkupRuleObject', 'HeraldRule' => array( 0 => 'HeraldDAO', diff --git a/src/applications/herald/application/PhabricatorApplicationHerald.php b/src/applications/herald/application/PhabricatorApplicationHerald.php index 1e0da3354f..4cc1ff8432 100644 --- a/src/applications/herald/application/PhabricatorApplicationHerald.php +++ b/src/applications/herald/application/PhabricatorApplicationHerald.php @@ -30,6 +30,12 @@ final class PhabricatorApplicationHerald extends PhabricatorApplication { return self::GROUP_ORGANIZATION; } + public function getRemarkupRules() { + return array( + new HeraldRemarkupRule(), + ); + } + public function getRoutes() { return array( '/herald/' => array( diff --git a/src/applications/herald/controller/HeraldRuleListController.php b/src/applications/herald/controller/HeraldRuleListController.php index bb52435d65..8d5ea7f95f 100644 --- a/src/applications/herald/controller/HeraldRuleListController.php +++ b/src/applications/herald/controller/HeraldRuleListController.php @@ -41,7 +41,7 @@ final class HeraldRuleListController extends HeraldController $id = $rule->getID(); $item = id(new PHUIObjectItemView()) - ->setObjectName(pht('Rule %s', $rule->getID())) + ->setObjectName("H{$id}") ->setHeader($rule->getName()) ->setHref($this->getApplicationURI("rule/{$id}/")); diff --git a/src/applications/herald/controller/HeraldRuleViewController.php b/src/applications/herald/controller/HeraldRuleViewController.php index d4c9577805..7e9105bdf1 100644 --- a/src/applications/herald/controller/HeraldRuleViewController.php +++ b/src/applications/herald/controller/HeraldRuleViewController.php @@ -41,10 +41,12 @@ final class HeraldRuleViewController extends HeraldController { $actions = $this->buildActionView($rule); $properties = $this->buildPropertyView($rule, $actions); + $id = $rule->getID(); + $crumbs = $this->buildApplicationCrumbs(); $crumbs->addCrumb( id(new PhabricatorCrumbView()) - ->setName(pht('Rule %d', $rule->getID()))); + ->setName("H{$id}")); $object_box = id(new PHUIObjectBoxView()) ->setHeader($header) diff --git a/src/applications/herald/engine/HeraldEngine.php b/src/applications/herald/engine/HeraldEngine.php index 04627b4eaf..685285b0b7 100644 --- a/src/applications/herald/engine/HeraldEngine.php +++ b/src/applications/herald/engine/HeraldEngine.php @@ -368,7 +368,9 @@ final class HeraldEngine { $name = $rule->getName(); $id = $rule->getID(); $effect->setReason( - 'Conditions were met for Herald rule "'.$name.'" (#'.$id.').'); + pht( + 'Conditions were met for %s', + "H{$id} {$name}")); $effects[] = $effect; } diff --git a/src/applications/herald/phid/HeraldPHIDTypeRule.php b/src/applications/herald/phid/HeraldPHIDTypeRule.php index a3022d3c0f..62b05c696d 100644 --- a/src/applications/herald/phid/HeraldPHIDTypeRule.php +++ b/src/applications/herald/phid/HeraldPHIDTypeRule.php @@ -35,9 +35,39 @@ final class HeraldPHIDTypeRule extends PhabricatorPHIDType { $id = $rule->getID(); $name = $rule->getName(); - $handle->setName($name); + $handle->setName("H{$id}"); + $handle->setFullName("H{$id} {$name}"); $handle->setURI("/herald/rule/{$id}/"); } } + public function canLoadNamedObject($name) { + return preg_match('/^H\d*[1-9]\d*$/i', $name); + } + + public function loadNamedObjects( + PhabricatorObjectQuery $query, + array $names) { + + $id_map = array(); + foreach ($names as $name) { + $id = (int)substr($name, 1); + $id_map[$id][] = $name; + } + + $objects = id(new HeraldRuleQuery()) + ->setViewer($query->getViewer()) + ->withIDs(array_keys($id_map)) + ->execute(); + + $results = array(); + foreach ($objects as $id => $object) { + foreach (idx($id_map, $id, array()) as $name) { + $results[$name] = $object; + } + } + + return $results; + } + } diff --git a/src/applications/herald/remarkup/HeraldRemarkupRule.php b/src/applications/herald/remarkup/HeraldRemarkupRule.php new file mode 100644 index 0000000000..be84526103 --- /dev/null +++ b/src/applications/herald/remarkup/HeraldRemarkupRule.php @@ -0,0 +1,18 @@ +getEngine()->getConfig('viewer'); + return id(new HeraldRuleQuery()) + ->setViewer($viewer) + ->withIDs($ids) + ->execute(); + } + +} diff --git a/src/applications/repository/worker/PhabricatorRepositoryCommitHeraldWorker.php b/src/applications/repository/worker/PhabricatorRepositoryCommitHeraldWorker.php index 3427628f5b..8c4201aafb 100644 --- a/src/applications/repository/worker/PhabricatorRepositoryCommitHeraldWorker.php +++ b/src/applications/repository/worker/PhabricatorRepositoryCommitHeraldWorker.php @@ -232,14 +232,12 @@ final class PhabricatorRepositoryCommitHeraldWorker } if ($status == PhabricatorAuditStatusConstants::AUDIT_REQUIRED) { $reasons[] = pht( - 'Herald Rule #%d "%s" Triggered Audit', - $id, - $rule_name); + '%s Triggered Audit', + "H{$id} {$rule_name}"); } else { $reasons[] = pht( - 'Herald Rule #%d "%s" Triggered CC', - $id, - $rule_name); + '%s Triggered CC', + "H{$id} {$rule_name}"); } }