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

Parse and display commit authorship date in Git in Diffusion

Summary: Fixes T8826. Git tracks an "author date", which may be different from the "committed date". We don't currently extract/show this; do so.

Test Plan: {F1059235}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T8826

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

+28 -4
+2
src/applications/diffusion/conduit/DiffusionQueryCommitsConduitAPIMethod.php
··· 79 79 'repositoryPHID' => $commit->getRepository()->getPHID(), 80 80 'identifier' => $commit->getCommitIdentifier(), 81 81 'epoch' => $commit->getEpoch(), 82 + 'authorEpoch' => $commit_data->getCommitDetail('authorEpoch'), 82 83 'uri' => $uri, 83 84 'isImporting' => !$commit->isImported(), 84 85 'summary' => $commit->getSummary(), ··· 99 100 ->withIdentifier($commit->getCommitIdentifier()) 100 101 ->execute(); 101 102 103 + $dict['authorEpoch'] = $lowlevel_commitref->getAuthorEpoch(); 102 104 $dict['author'] = $lowlevel_commitref->getAuthor(); 103 105 $dict['authorName'] = $lowlevel_commitref->getAuthorName(); 104 106 $dict['authorEmail'] = $lowlevel_commitref->getAuthorEmail();
+6 -2
src/applications/diffusion/controller/DiffusionCommitController.php
··· 492 492 493 493 if (!$repository->isSVN()) { 494 494 $authored_info = id(new PHUIStatusItemView()); 495 - // TODO: In Git, a distinct authorship date is available. When present, 496 - // we should show it here. 495 + 496 + $author_epoch = $data->getCommitDetail('authorEpoch'); 497 + if ($author_epoch !== null) { 498 + $authored_info->setNote( 499 + phabricator_datetime($author_epoch, $viewer)); 500 + } 497 501 498 502 if ($author_phid) { 499 503 $authored_info->setTarget($handles[$author_phid]->renderLink());
+11
src/applications/diffusion/data/DiffusionCommitRef.php
··· 3 3 final class DiffusionCommitRef extends Phobject { 4 4 5 5 private $message; 6 + private $authorEpoch; 6 7 private $authorName; 7 8 private $authorEmail; 8 9 private $committerName; ··· 11 12 12 13 public static function newFromConduitResult(array $result) { 13 14 $ref = id(new DiffusionCommitRef()) 15 + ->setAuthorEpoch(idx($result, 'authorEpoch')) 14 16 ->setCommitterEmail(idx($result, 'committerEmail')) 15 17 ->setCommitterName(idx($result, 'committerName')) 16 18 ->setAuthorEmail(idx($result, 'authorEmail')) ··· 36 38 37 39 public function getHashes() { 38 40 return $this->hashes; 41 + } 42 + 43 + public function setAuthorEpoch($author_epoch) { 44 + $this->authorEpoch = $author_epoch; 45 + return $this; 46 + } 47 + 48 + public function getAuthorEpoch() { 49 + return $this->authorEpoch; 39 50 } 40 51 41 52 public function setCommitterEmail($committer_email) {
+8 -2
src/applications/diffusion/query/lowlevel/DiffusionLowLevelCommitQuery.php
··· 52 52 'UTF-8', 53 53 implode( 54 54 '%x00', 55 - array('%e', '%cn', '%ce', '%an', '%ae', '%T', '%s%n%n%b')), 55 + array('%e', '%cn', '%ce', '%an', '%ae', '%T', '%at', '%s%n%n%b')), 56 56 $this->identifier); 57 57 58 58 $parts = explode("\0", $info); ··· 77 77 ->setHashValue($parts[4]), 78 78 ); 79 79 80 + $author_epoch = (int)$parts[5]; 81 + if (!$author_epoch) { 82 + $author_epoch = null; 83 + } 84 + 80 85 return id(new DiffusionCommitRef()) 81 86 ->setCommitterName($parts[0]) 82 87 ->setCommitterEmail($parts[1]) 83 88 ->setAuthorName($parts[2]) 84 89 ->setAuthorEmail($parts[3]) 85 90 ->setHashes($hashes) 86 - ->setMessage($parts[5]); 91 + ->setAuthorEpoch($author_epoch) 92 + ->setMessage($parts[6]); 87 93 } 88 94 89 95 private function loadMercurialCommitRef() {
+1
src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php
··· 58 58 ->setMaximumBytes(255) 59 59 ->truncateString((string)$author)); 60 60 61 + $data->setCommitDetail('authorEpoch', $ref->getAuthorEpoch()); 61 62 $data->setCommitDetail('authorName', $ref->getAuthorName()); 62 63 $data->setCommitDetail('authorEmail', $ref->getAuthorEmail()); 63 64