2011-04-11 03:02:19 -07:00
|
|
|
<?php
|
|
|
|
|
2014-08-05 00:55:43 +10:00
|
|
|
final class DiffusionCommitRemarkupRule extends PhabricatorObjectRemarkupRule {
|
2011-04-11 03:02:19 -07:00
|
|
|
|
2012-12-12 13:46:28 -08:00
|
|
|
protected function getObjectNamePrefix() {
|
2013-02-27 08:04:54 -08:00
|
|
|
return '';
|
2011-04-11 03:02:19 -07:00
|
|
|
}
|
|
|
|
|
2013-05-20 13:27:03 -07:00
|
|
|
protected function getObjectNamePrefixBeginsWithWordCharacter() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-12-12 13:46:28 -08:00
|
|
|
protected function getObjectIDPattern() {
|
2014-07-24 08:05:46 +10:00
|
|
|
return PhabricatorRepositoryCommitPHIDType::getCommitObjectNamePattern();
|
2013-02-27 08:04:54 -08:00
|
|
|
}
|
|
|
|
|
2016-08-24 06:24:05 -07:00
|
|
|
protected function getObjectNameText(
|
|
|
|
$object,
|
|
|
|
PhabricatorObjectHandle $handle,
|
|
|
|
$id) {
|
|
|
|
|
|
|
|
// If this commit is unreachable, return the handle name instead of the
|
|
|
|
// normal text because it may be able to tell the user that the commit
|
|
|
|
// was rewritten and where to find the new one.
|
|
|
|
|
|
|
|
// By default, we try to preserve what the user actually typed as
|
|
|
|
// faithfully as possible, but if they're referencing a deleted commit
|
|
|
|
// it's more valuable to try to pick up any rewrite. See T11522.
|
|
|
|
if ($object->isUnreachable()) {
|
|
|
|
return $handle->getName();
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::getObjectNameText($object, $handle, $id);
|
|
|
|
}
|
|
|
|
|
2013-02-27 08:04:54 -08:00
|
|
|
protected function loadObjects(array $ids) {
|
|
|
|
$viewer = $this->getEngine()->getConfig('viewer');
|
|
|
|
|
2013-07-21 10:57:07 -07:00
|
|
|
$query = id(new DiffusionCommitQuery())
|
2013-02-27 08:04:54 -08:00
|
|
|
->setViewer($viewer)
|
2013-07-21 10:57:07 -07:00
|
|
|
->withIdentifiers($ids);
|
2013-02-27 08:04:54 -08:00
|
|
|
|
2013-07-21 10:57:07 -07:00
|
|
|
$query->execute();
|
|
|
|
return $query->getIdentifierMap();
|
2011-04-11 03:02:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|