@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
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+40 -12
+1 -1
src/applications/diffusion/controller/DiffusionBrowseController.php
··· 1761 1761 'size' => 600, 1762 1762 ), 1763 1763 ), 1764 - $commit->getShortName()); 1764 + $commit->getLocalName()); 1765 1765 1766 1766 $links[$identifier] = $commit_link; 1767 1767 }
+1 -1
src/applications/diffusion/view/DiffusionView.php
··· 128 128 $commit, 129 129 $summary = '') { 130 130 131 - $commit_name = $repository->formatCommitName($commit); 131 + $commit_name = $repository->formatCommitName($commit, $local = true); 132 132 133 133 if (strlen($summary)) { 134 134 $commit_name .= ': '.$summary;
+10 -4
src/applications/repository/query/PhabricatorRepositorySearchEngine.php
··· 160 160 161 161 $commit = $repository->getMostRecentCommit(); 162 162 if ($commit) { 163 - $commit_link = DiffusionView::linkCommit( 164 - $repository, 165 - $commit->getCommitIdentifier(), 166 - $commit->getSummary()); 163 + $commit_link = phutil_tag( 164 + 'a', 165 + array( 166 + 'href' => $commit->getURI(), 167 + ), 168 + pht( 169 + '%s: %s', 170 + $commit->getLocalName(), 171 + $commit->getSummary())); 172 + 167 173 $item->setSubhead($commit_link); 168 174 $item->setEpoch($commit->getEpoch()); 169 175 }
+15 -4
src/applications/repository/storage/PhabricatorRepository.php
··· 924 924 return $this->isBranchInFilter($branch, 'branch-filter'); 925 925 } 926 926 927 - public function formatCommitName($commit_identifier) { 927 + public function formatCommitName($commit_identifier, $local = false) { 928 928 $vcs = $this->getVersionControlSystem(); 929 929 930 930 $type_git = PhabricatorRepositoryType::REPOSITORY_TYPE_GIT; ··· 933 933 $is_git = ($vcs == $type_git); 934 934 $is_hg = ($vcs == $type_hg); 935 935 if ($is_git || $is_hg) { 936 - $short_identifier = substr($commit_identifier, 0, 12); 936 + $name = substr($commit_identifier, 0, 12); 937 + $need_scope = false; 937 938 } else { 938 - $short_identifier = $commit_identifier; 939 + $name = $commit_identifier; 940 + $need_scope = true; 941 + } 942 + 943 + if (!$local) { 944 + $need_scope = true; 945 + } 946 + 947 + if ($need_scope) { 948 + $scope = 'r'.$this->getCallsign(); 949 + $name = $scope.$name; 939 950 } 940 951 941 - return 'r'.$this->getCallsign().$short_identifier; 952 + return $name; 942 953 } 943 954 944 955 public function isImporting() {
+13 -2
src/applications/repository/storage/PhabricatorRepositoryCommit.php
··· 266 266 return $repository->formatCommitName($identifier); 267 267 } 268 268 269 - public function getShortName() { 269 + /** 270 + * Return a local display name for use in the context of the containing 271 + * repository. 272 + * 273 + * In Git and Mercurial, this returns only a short hash, like "abcdef012345". 274 + * See @{method:getDisplayName} for a short name that always includes 275 + * repository context. 276 + * 277 + * @return string Short human-readable name for use inside a repository. 278 + */ 279 + public function getLocalName() { 280 + $repository = $this->getRepository(); 270 281 $identifier = $this->getCommitIdentifier(); 271 - return substr($identifier, 0, 9); 282 + return $repository->formatCommitName($identifier, $local = true); 272 283 } 273 284 274 285 public function renderAuthorLink($handles) {