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

Render commit summaries when rendering handles

Summary:
Fixes T2563. Instead of rendering "rPnnnnnn", render "rPnnnnnn: add feature X". Tweak Audit tables to accommodate.

@vrana / @nh, this migration might take a while. You could safely skip it when deploying and then run it after deployment.

I think I fixed all the other places where these render, but might have missed something.

Test Plan:
- Ran first schema migration, clicked around to make sure nothing broke.
- Ran `scripts/repository/reparse.php --message rXyyyyy`, verified summary populated.
- Ran second migration.
- Checked task/diffusion/audit/differential for weird rendering.

Reviewers: vrana

Reviewed By: vrana

CC: nh, aran, chrisbolt, allixsenos

Maniphest Tasks: T2563

Differential Revision: https://secure.phabricator.com/D5012

+64 -29
+2
resources/sql/patches/20130219.commitsummary.sql
··· 1 + ALTER TABLE {$NAMESPACE}_repository.repository_commit 2 + ADD summary VARCHAR(80) NOT NULL;
+25
resources/sql/patches/20130219.commitsummarymig.php
··· 1 + <?php 2 + 3 + echo "Backfilling commit summaries...\n"; 4 + 5 + $commits = new LiskMigrationIterator(new PhabricatorRepositoryCommit()); 6 + foreach ($commits as $commit) { 7 + echo 'Filling Commit #'.$commit->getID()."\n"; 8 + 9 + if (strlen($commit->getSummary())) { 10 + continue; 11 + } 12 + 13 + $data = id(new PhabricatorRepositoryCommitData())->loadOneWhere( 14 + 'commitID = %d', 15 + $commit->getID()); 16 + 17 + if (!$data) { 18 + continue; 19 + } 20 + 21 + $commit->setSummary($data->getSummary()); 22 + $commit->save(); 23 + } 24 + 25 + echo "Done.\n";
+1 -5
src/applications/audit/view/PhabricatorAuditCommitListView.php
··· 70 70 $rows[] = array( 71 71 $commit_name, 72 72 $author_name, 73 - $commit->getCommitData()->getSummary(), 74 73 PhabricatorAuditCommitStatusConstants::getStatusName( 75 74 $commit->getAuditStatus()), 76 75 phutil_implode_html(', ', $auditors), ··· 83 82 array( 84 83 'Commit', 85 84 'Author', 86 - 'Summary', 87 85 'Audit Status', 88 86 'Auditors', 89 87 'Date', 90 88 )); 91 89 $table->setColumnClasses( 92 90 array( 93 - 'n', 94 - '', 95 91 'wide', 92 + '', 96 93 '', 97 94 '', 98 95 '', ··· 101 98 if ($this->commits && reset($this->commits)->getAudits() === null) { 102 99 $table->setColumnVisibility( 103 100 array( 104 - true, 105 101 true, 106 102 true, 107 103 true,
+6 -10
src/applications/audit/view/PhabricatorAuditListView.php
··· 7 7 private $authorityPHIDs = array(); 8 8 private $noDataString; 9 9 private $commits; 10 - private $showDescriptions = true; 10 + private $showCommits = true; 11 11 12 12 private $highlightedAudits; 13 13 ··· 43 43 return $this; 44 44 } 45 45 46 - public function setShowDescriptions($show_descriptions) { 47 - $this->showDescriptions = $show_descriptions; 46 + public function setShowCommits($show_commits) { 47 + $this->showCommits = $show_commits; 48 48 return $this; 49 49 } 50 50 ··· 137 137 $auditor_handle = $this->getHandle($audit->getAuditorPHID()); 138 138 $rows[] = array( 139 139 $commit_name, 140 - $commit_desc, 141 140 $committed, 142 141 $auditor_handle->renderLink(), 143 142 $status, ··· 155 154 $table->setHeaders( 156 155 array( 157 156 'Commit', 158 - 'Description', 159 157 'Committed', 160 158 'Auditor', 161 159 'Status', ··· 164 162 $table->setColumnClasses( 165 163 array( 166 164 'pri', 167 - ($this->showDescriptions ? 'wide' : ''), 168 165 '', 169 166 '', 170 167 '', 171 - ($this->showDescriptions ? '' : 'wide'), 168 + ($this->showCommits ? '' : 'wide'), 172 169 )); 173 170 $table->setRowClasses($rowc); 174 171 $table->setColumnVisibility( 175 172 array( 176 - $this->showDescriptions, 177 - $this->showDescriptions, 178 - $this->showDescriptions, 173 + $this->showCommits, 174 + $this->showCommits, 179 175 true, 180 176 true, 181 177 true,
+2 -2
src/applications/diffusion/controller/DiffusionCommitController.php
··· 75 75 $drequest); 76 76 77 77 $headsup_view = id(new PhabricatorHeaderView()) 78 - ->setHeader('Commit Detail'); 78 + ->setHeader(nonempty($commit->getSummary(), pht('Commit Detail'))); 79 79 80 80 $headsup_actions = $this->renderHeadsupActionList($commit, $repository); 81 81 ··· 504 504 $view->setAudits($audits); 505 505 $view->setCommits(array($commit)); 506 506 $view->setUser($user); 507 - $view->setShowDescriptions(false); 507 + $view->setShowCommits(false); 508 508 509 509 $phids = $view->getRequiredHandlePHIDs(); 510 510 $handles = $this->loadViewerHandles($phids);
-1
src/applications/phid/PhabricatorObjectHandle.php
··· 203 203 public function getLinkName() { 204 204 switch ($this->getType()) { 205 205 case PhabricatorPHIDConstants::PHID_TYPE_USER: 206 - case PhabricatorPHIDConstants::PHID_TYPE_CMIT: 207 206 $name = $this->getName(); 208 207 break; 209 208 default:
+9 -7
src/applications/phid/handle/PhabricatorObjectHandleData.php
··· 328 328 $handle = new PhabricatorObjectHandle(); 329 329 $handle->setPHID($phid); 330 330 $handle->setType($type); 331 + 331 332 $repository = null; 332 333 if (!empty($objects[$phid])) { 333 334 $repository = $objects[$phid]->loadOneRelative( ··· 335 336 'id', 336 337 'getRepositoryID'); 337 338 } 339 + 338 340 if (!$repository) { 339 341 $handle->setName('Unknown Commit'); 340 342 } else { ··· 342 344 $callsign = $repository->getCallsign(); 343 345 $commit_identifier = $commit->getCommitIdentifier(); 344 346 345 - // In case where the repository for the commit was deleted, 346 - // we don't have info about the repository anymore. 347 - if ($repository) { 348 - $name = $repository->formatCommitName($commit_identifier); 349 - $handle->setName($name); 347 + $name = $repository->formatCommitName($commit_identifier); 348 + $handle->setName($name); 349 + 350 + $summary = $commit->getSummary(); 351 + if (strlen($summary)) { 352 + $handle->setFullName($name.': '.$summary); 350 353 } else { 351 - $handle->setName('Commit '.'r'.$callsign.$commit_identifier); 354 + $handle->setFullName($name); 352 355 } 353 356 354 357 $handle->setURI('/r'.$callsign.$commit_identifier); 355 - $handle->setFullName('r'.$callsign.$commit_identifier); 356 358 $handle->setTimestamp($commit->getEpoch()); 357 359 $handle->setComplete(true); 358 360 }
+1
src/applications/repository/storage/PhabricatorRepositoryCommit.php
··· 9 9 protected $mailKey; 10 10 protected $authorPHID; 11 11 protected $auditStatus = PhabricatorAuditCommitStatusConstants::NONE; 12 + protected $summary = ''; 12 13 13 14 private $commitData; 14 15 private $audits;
+7 -3
src/applications/repository/storage/PhabricatorRepositoryCommitData.php
··· 2 2 3 3 final class PhabricatorRepositoryCommitData extends PhabricatorRepositoryDAO { 4 4 5 - const SUMMARY_MAX_LENGTH = 100; 5 + /** 6 + * NOTE: We denormalize this into the commit table; make sure the sizes 7 + * match up. 8 + */ 9 + const SUMMARY_MAX_LENGTH = 80; 6 10 7 11 protected $commitID; 8 12 protected $authorName = ''; ··· 20 24 21 25 public function getSummary() { 22 26 $message = $this->getCommitMessage(); 23 - $lines = explode("\n", $message); 24 - $summary = head($lines); 25 27 28 + $summary = phutil_split_lines($message); 29 + $summary = head($summary); 26 30 $summary = phutil_utf8_shorten($summary, self::SUMMARY_MAX_LENGTH); 27 31 28 32 return $summary;
+3 -1
src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php
··· 77 77 78 78 if ($author_phid != $commit->getAuthorPHID()) { 79 79 $commit->setAuthorPHID($author_phid); 80 - $commit->save(); 81 80 } 81 + 82 + $commit->setSummary($data->getSummary()); 83 + $commit->save(); 82 84 83 85 $conn_w = id(new DifferentialRevision())->establishConnection('w'); 84 86
+8
src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php
··· 1137 1137 'type' => 'sql', 1138 1138 'name' => $this->getPatchPath('20130218.longdaemon.sql'), 1139 1139 ), 1140 + '20130219.commitsummary.sql' => array( 1141 + 'type' => 'sql', 1142 + 'name' => $this->getPatchPath('20130219.commitsummary.sql'), 1143 + ), 1144 + '20130219.commitsummarymig.php' => array( 1145 + 'type' => 'php', 1146 + 'name' => $this->getPatchPath('20130219.commitsummarymig.php'), 1147 + ), 1140 1148 '20130215.phabricatorfileaddttl.sql' => array( 1141 1149 'type' => 'sql', 1142 1150 'name' => $this->getPatchPath('20130215.phabricatorfileaddttl.sql'),