mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 22:10:55 +01:00
Introduce "local names" for commits
Summary: Ref T4245. Full commit display names (like `rPaaaa`) are going to be obnoxious soon in some cases (e.g., `rPaaaa` becomes `R123:aaaa`, which is much uglier) so reduce how often we show the repository in cases where it isn't really necessary to include it. Test Plan: - Saw no more `rX` on repository list view for Git/Mercurial (still present for Subversion). - Saw no more `rX` on various repository detail views, except when referencing other commits (e.g., mentions). - Grepped for removed `getShortName()`. Reviewers: chad Reviewed By: chad Maniphest Tasks: T4245 Differential Revision: https://secure.phabricator.com/D14990
This commit is contained in:
parent
96ebd35824
commit
b848ab87b3
5 changed files with 40 additions and 12 deletions
|
@ -1761,7 +1761,7 @@ final class DiffusionBrowseController extends DiffusionController {
|
||||||
'size' => 600,
|
'size' => 600,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
$commit->getShortName());
|
$commit->getLocalName());
|
||||||
|
|
||||||
$links[$identifier] = $commit_link;
|
$links[$identifier] = $commit_link;
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,7 +128,7 @@ abstract class DiffusionView extends AphrontView {
|
||||||
$commit,
|
$commit,
|
||||||
$summary = '') {
|
$summary = '') {
|
||||||
|
|
||||||
$commit_name = $repository->formatCommitName($commit);
|
$commit_name = $repository->formatCommitName($commit, $local = true);
|
||||||
|
|
||||||
if (strlen($summary)) {
|
if (strlen($summary)) {
|
||||||
$commit_name .= ': '.$summary;
|
$commit_name .= ': '.$summary;
|
||||||
|
|
|
@ -160,10 +160,16 @@ final class PhabricatorRepositorySearchEngine
|
||||||
|
|
||||||
$commit = $repository->getMostRecentCommit();
|
$commit = $repository->getMostRecentCommit();
|
||||||
if ($commit) {
|
if ($commit) {
|
||||||
$commit_link = DiffusionView::linkCommit(
|
$commit_link = phutil_tag(
|
||||||
$repository,
|
'a',
|
||||||
$commit->getCommitIdentifier(),
|
array(
|
||||||
$commit->getSummary());
|
'href' => $commit->getURI(),
|
||||||
|
),
|
||||||
|
pht(
|
||||||
|
'%s: %s',
|
||||||
|
$commit->getLocalName(),
|
||||||
|
$commit->getSummary()));
|
||||||
|
|
||||||
$item->setSubhead($commit_link);
|
$item->setSubhead($commit_link);
|
||||||
$item->setEpoch($commit->getEpoch());
|
$item->setEpoch($commit->getEpoch());
|
||||||
}
|
}
|
||||||
|
|
|
@ -924,7 +924,7 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
|
||||||
return $this->isBranchInFilter($branch, 'branch-filter');
|
return $this->isBranchInFilter($branch, 'branch-filter');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function formatCommitName($commit_identifier) {
|
public function formatCommitName($commit_identifier, $local = false) {
|
||||||
$vcs = $this->getVersionControlSystem();
|
$vcs = $this->getVersionControlSystem();
|
||||||
|
|
||||||
$type_git = PhabricatorRepositoryType::REPOSITORY_TYPE_GIT;
|
$type_git = PhabricatorRepositoryType::REPOSITORY_TYPE_GIT;
|
||||||
|
@ -933,12 +933,23 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
|
||||||
$is_git = ($vcs == $type_git);
|
$is_git = ($vcs == $type_git);
|
||||||
$is_hg = ($vcs == $type_hg);
|
$is_hg = ($vcs == $type_hg);
|
||||||
if ($is_git || $is_hg) {
|
if ($is_git || $is_hg) {
|
||||||
$short_identifier = substr($commit_identifier, 0, 12);
|
$name = substr($commit_identifier, 0, 12);
|
||||||
|
$need_scope = false;
|
||||||
} else {
|
} else {
|
||||||
$short_identifier = $commit_identifier;
|
$name = $commit_identifier;
|
||||||
|
$need_scope = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'r'.$this->getCallsign().$short_identifier;
|
if (!$local) {
|
||||||
|
$need_scope = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($need_scope) {
|
||||||
|
$scope = 'r'.$this->getCallsign();
|
||||||
|
$name = $scope.$name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isImporting() {
|
public function isImporting() {
|
||||||
|
|
|
@ -266,9 +266,20 @@ final class PhabricatorRepositoryCommit
|
||||||
return $repository->formatCommitName($identifier);
|
return $repository->formatCommitName($identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getShortName() {
|
/**
|
||||||
|
* Return a local display name for use in the context of the containing
|
||||||
|
* repository.
|
||||||
|
*
|
||||||
|
* In Git and Mercurial, this returns only a short hash, like "abcdef012345".
|
||||||
|
* See @{method:getDisplayName} for a short name that always includes
|
||||||
|
* repository context.
|
||||||
|
*
|
||||||
|
* @return string Short human-readable name for use inside a repository.
|
||||||
|
*/
|
||||||
|
public function getLocalName() {
|
||||||
|
$repository = $this->getRepository();
|
||||||
$identifier = $this->getCommitIdentifier();
|
$identifier = $this->getCommitIdentifier();
|
||||||
return substr($identifier, 0, 9);
|
return $repository->formatCommitName($identifier, $local = true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function renderAuthorLink($handles) {
|
public function renderAuthorLink($handles) {
|
||||||
|
|
Loading…
Reference in a new issue