1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-09 14:21:02 +01:00

Add a Diffusion repository remarkup rule

Summary: Currently we markup `rXabcd`, but not `rX` on its own. Mark these up as repository object names.

Test Plan: Typed `rPOEMS`, `rPOEMS1`, `rPOEMS139893189`, etc.

Reviewers: btrahan, dctrwatson

Reviewed By: btrahan

CC: aran, poop

Differential Revision: https://secure.phabricator.com/D7859
This commit is contained in:
epriestley 2013-12-31 11:08:08 -08:00
parent db89883447
commit c20fd58303
5 changed files with 35 additions and 5 deletions

View file

@ -483,6 +483,7 @@ phutil_register_library_map(array(
'DiffusionCommitHookRejectException' => 'applications/diffusion/exception/DiffusionCommitHookRejectException.php',
'DiffusionCommitQuery' => 'applications/diffusion/query/DiffusionCommitQuery.php',
'DiffusionCommitRef' => 'applications/diffusion/data/DiffusionCommitRef.php',
'DiffusionCommitRemarkupRule' => 'applications/diffusion/remarkup/DiffusionCommitRemarkupRule.php',
'DiffusionCommitTagsController' => 'applications/diffusion/controller/DiffusionCommitTagsController.php',
'DiffusionController' => 'applications/diffusion/controller/DiffusionController.php',
'DiffusionDiffController' => 'applications/diffusion/controller/DiffusionDiffController.php',
@ -530,7 +531,6 @@ phutil_register_library_map(array(
'DiffusionPushLogListController' => 'applications/diffusion/controller/DiffusionPushLogListController.php',
'DiffusionQuery' => 'applications/diffusion/query/DiffusionQuery.php',
'DiffusionRawDiffQuery' => 'applications/diffusion/query/rawdiff/DiffusionRawDiffQuery.php',
'DiffusionRemarkupRule' => 'applications/diffusion/remarkup/DiffusionRemarkupRule.php',
'DiffusionRenameHistoryQuery' => 'applications/diffusion/query/DiffusionRenameHistoryQuery.php',
'DiffusionRepositoryController' => 'applications/diffusion/controller/DiffusionRepositoryController.php',
'DiffusionRepositoryCreateController' => 'applications/diffusion/controller/DiffusionRepositoryCreateController.php',
@ -551,6 +551,7 @@ phutil_register_library_map(array(
'DiffusionRepositoryNewController' => 'applications/diffusion/controller/DiffusionRepositoryNewController.php',
'DiffusionRepositoryPath' => 'applications/diffusion/data/DiffusionRepositoryPath.php',
'DiffusionRepositoryRef' => 'applications/diffusion/data/DiffusionRepositoryRef.php',
'DiffusionRepositoryRemarkupRule' => 'applications/diffusion/remarkup/DiffusionRepositoryRemarkupRule.php',
'DiffusionRepositoryTag' => 'applications/diffusion/data/DiffusionRepositoryTag.php',
'DiffusionRequest' => 'applications/diffusion/request/DiffusionRequest.php',
'DiffusionResolveUserQuery' => 'applications/diffusion/query/DiffusionResolveUserQuery.php',
@ -2886,6 +2887,7 @@ phutil_register_library_map(array(
'DiffusionCommitHookRejectException' => 'Exception',
'DiffusionCommitQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'DiffusionCommitRef' => 'Phobject',
'DiffusionCommitRemarkupRule' => 'PhabricatorRemarkupRuleObject',
'DiffusionCommitTagsController' => 'DiffusionController',
'DiffusionController' => 'PhabricatorController',
'DiffusionDiffController' => 'DiffusionController',
@ -2929,7 +2931,6 @@ phutil_register_library_map(array(
),
'DiffusionQuery' => 'PhabricatorQuery',
'DiffusionRawDiffQuery' => 'DiffusionQuery',
'DiffusionRemarkupRule' => 'PhabricatorRemarkupRuleObject',
'DiffusionRepositoryController' => 'DiffusionController',
'DiffusionRepositoryCreateController' => 'DiffusionRepositoryEditController',
'DiffusionRepositoryDefaultController' => 'DiffusionController',
@ -2951,6 +2952,7 @@ phutil_register_library_map(array(
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
),
'DiffusionRepositoryNewController' => 'DiffusionController',
'DiffusionRepositoryRemarkupRule' => 'PhabricatorRemarkupRuleObject',
'DiffusionResolveUserQuery' => 'Phobject',
'DiffusionSSHGitReceivePackWorkflow' => 'DiffusionSSHGitWorkflow',
'DiffusionSSHGitUploadPackWorkflow' => 'DiffusionSSHGitWorkflow',

View file

@ -32,7 +32,8 @@ final class PhabricatorApplicationDiffusion extends PhabricatorApplication {
public function getRemarkupRules() {
return array(
new DiffusionRemarkupRule(),
new DiffusionRepositoryRemarkupRule(),
new DiffusionCommitRemarkupRule(),
);
}

View file

@ -76,11 +76,13 @@ final class DiffusionCommitQuery
return $this->identifierMap;
}
protected function loadPage() {
protected function willExecute() {
if ($this->identifierMap === null) {
$this->identifierMap = array();
}
}
protected function loadPage() {
$table = new PhabricatorRepositoryCommit();
$conn_r = $table->establishConnection('r');

View file

@ -1,6 +1,6 @@
<?php
final class DiffusionRemarkupRule
final class DiffusionCommitRemarkupRule
extends PhabricatorRemarkupRuleObject {
protected function getObjectNamePrefix() {

View file

@ -0,0 +1,25 @@
<?php
final class DiffusionRepositoryRemarkupRule
extends PhabricatorRemarkupRuleObject {
protected function getObjectNamePrefix() {
return 'r';
}
protected function getObjectIDPattern() {
return '[A-Z]+';
}
protected function loadObjects(array $ids) {
$viewer = $this->getEngine()->getConfig('viewer');
$repositories = id(new PhabricatorRepositoryQuery())
->setViewer($viewer)
->withCallsigns($ids)
->execute();
return mpull($repositories, null, 'getCallsign');
}
}