Page MenuHomePhabricator

D7786.diff
No OneTemporary

D7786.diff

Index: src/__phutil_library_map__.php
===================================================================
--- src/__phutil_library_map__.php
+++ src/__phutil_library_map__.php
@@ -758,6 +758,7 @@
'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 @@
'HeraldPholioMockAdapter' => 'HeraldAdapter',
'HeraldPreCommitRefAdapter' => 'HeraldAdapter',
'HeraldRecursiveConditionsException' => 'Exception',
+ 'HeraldRemarkupRule' => 'PhabricatorRemarkupRuleObject',
'HeraldRule' =>
array(
0 => 'HeraldDAO',
Index: src/applications/herald/application/PhabricatorApplicationHerald.php
===================================================================
--- src/applications/herald/application/PhabricatorApplicationHerald.php
+++ src/applications/herald/application/PhabricatorApplicationHerald.php
@@ -30,6 +30,12 @@
return self::GROUP_ORGANIZATION;
}
+ public function getRemarkupRules() {
+ return array(
+ new HeraldRemarkupRule(),
+ );
+ }
+
public function getRoutes() {
return array(
'/herald/' => array(
Index: src/applications/herald/controller/HeraldRuleListController.php
===================================================================
--- src/applications/herald/controller/HeraldRuleListController.php
+++ src/applications/herald/controller/HeraldRuleListController.php
@@ -41,7 +41,7 @@
$id = $rule->getID();
$item = id(new PHUIObjectItemView())
- ->setObjectName(pht('Rule %s', $rule->getID()))
+ ->setObjectName("H{$id}")
->setHeader($rule->getName())
->setHref($this->getApplicationURI("rule/{$id}/"));
Index: src/applications/herald/controller/HeraldRuleViewController.php
===================================================================
--- src/applications/herald/controller/HeraldRuleViewController.php
+++ src/applications/herald/controller/HeraldRuleViewController.php
@@ -41,10 +41,12 @@
$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)
Index: src/applications/herald/engine/HeraldEngine.php
===================================================================
--- src/applications/herald/engine/HeraldEngine.php
+++ src/applications/herald/engine/HeraldEngine.php
@@ -368,7 +368,9 @@
$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;
}
Index: src/applications/herald/phid/HeraldPHIDTypeRule.php
===================================================================
--- src/applications/herald/phid/HeraldPHIDTypeRule.php
+++ src/applications/herald/phid/HeraldPHIDTypeRule.php
@@ -35,9 +35,39 @@
$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;
+ }
+
}
Index: src/applications/herald/remarkup/HeraldRemarkupRule.php
===================================================================
--- /dev/null
+++ src/applications/herald/remarkup/HeraldRemarkupRule.php
@@ -0,0 +1,18 @@
+<?php
+
+final class HeraldRemarkupRule
+ extends PhabricatorRemarkupRuleObject {
+
+ protected function getObjectNamePrefix() {
+ return 'H';
+ }
+
+ protected function loadObjects(array $ids) {
+ $viewer = $this->getEngine()->getConfig('viewer');
+ return id(new HeraldRuleQuery())
+ ->setViewer($viewer)
+ ->withIDs($ids)
+ ->execute();
+ }
+
+}
Index: src/applications/repository/worker/PhabricatorRepositoryCommitHeraldWorker.php
===================================================================
--- src/applications/repository/worker/PhabricatorRepositoryCommitHeraldWorker.php
+++ src/applications/repository/worker/PhabricatorRepositoryCommitHeraldWorker.php
@@ -232,14 +232,12 @@
}
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}");
}
}

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 4, 6:33 AM (2 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6746966
Default Alt Text
D7786.diff (6 KB)

Event Timeline