@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<?php
2
3final class DiffusionCommitRemarkupRule extends PhabricatorObjectRemarkupRule {
4
5 protected function getObjectNamePrefix() {
6 return '';
7 }
8
9 protected function getObjectNamePrefixBeginsWithWordCharacter() {
10 return true;
11 }
12
13 /**
14 * @return string Regex which defines a valid object ID
15 */
16 protected function getObjectIDPattern() {
17 return PhabricatorRepositoryCommitPHIDType::getCommitObjectNamePattern();
18 }
19
20 protected function getObjectNameText(
21 $object,
22 PhabricatorObjectHandle $handle,
23 $id) {
24
25 // If this commit is unreachable, return the handle name instead of the
26 // normal text because it may be able to tell the user that the commit
27 // was rewritten and where to find the new one.
28
29 // By default, we try to preserve what the user actually typed as
30 // faithfully as possible, but if they're referencing a deleted commit
31 // it's more valuable to try to pick up any rewrite. See T11522.
32 if ($object->isUnreachable()) {
33 return $handle->getName();
34 }
35
36 return parent::getObjectNameText($object, $handle, $id);
37 }
38
39 protected function loadObjects(array $ids) {
40 $viewer = $this->getEngine()->getConfig('viewer');
41
42 $query = id(new DiffusionCommitQuery())
43 ->setViewer($viewer)
44 ->withIdentifiers($ids);
45
46 $query->execute();
47 return $query->getIdentifierMap();
48 }
49
50}