1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 14:00:56 +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:
epriestley 2016-01-11 02:49:04 -08:00
parent 96ebd35824
commit b848ab87b3
5 changed files with 40 additions and 12 deletions

View file

@ -1761,7 +1761,7 @@ final class DiffusionBrowseController extends DiffusionController {
'size' => 600,
),
),
$commit->getShortName());
$commit->getLocalName());
$links[$identifier] = $commit_link;
}

View file

@ -128,7 +128,7 @@ abstract class DiffusionView extends AphrontView {
$commit,
$summary = '') {
$commit_name = $repository->formatCommitName($commit);
$commit_name = $repository->formatCommitName($commit, $local = true);
if (strlen($summary)) {
$commit_name .= ': '.$summary;

View file

@ -160,10 +160,16 @@ final class PhabricatorRepositorySearchEngine
$commit = $repository->getMostRecentCommit();
if ($commit) {
$commit_link = DiffusionView::linkCommit(
$repository,
$commit->getCommitIdentifier(),
$commit->getSummary());
$commit_link = phutil_tag(
'a',
array(
'href' => $commit->getURI(),
),
pht(
'%s: %s',
$commit->getLocalName(),
$commit->getSummary()));
$item->setSubhead($commit_link);
$item->setEpoch($commit->getEpoch());
}

View file

@ -924,7 +924,7 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
return $this->isBranchInFilter($branch, 'branch-filter');
}
public function formatCommitName($commit_identifier) {
public function formatCommitName($commit_identifier, $local = false) {
$vcs = $this->getVersionControlSystem();
$type_git = PhabricatorRepositoryType::REPOSITORY_TYPE_GIT;
@ -933,12 +933,23 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
$is_git = ($vcs == $type_git);
$is_hg = ($vcs == $type_hg);
if ($is_git || $is_hg) {
$short_identifier = substr($commit_identifier, 0, 12);
$name = substr($commit_identifier, 0, 12);
$need_scope = false;
} 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() {

View file

@ -266,9 +266,20 @@ final class PhabricatorRepositoryCommit
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();
return substr($identifier, 0, 9);
return $repository->formatCommitName($identifier, $local = true);
}
public function renderAuthorLink($handles) {