diff --git a/src/applications/diffusion/conduit/DiffusionQueryCommitsConduitAPIMethod.php b/src/applications/diffusion/conduit/DiffusionQueryCommitsConduitAPIMethod.php index 3bb69276c8..a71b21a724 100644 --- a/src/applications/diffusion/conduit/DiffusionQueryCommitsConduitAPIMethod.php +++ b/src/applications/diffusion/conduit/DiffusionQueryCommitsConduitAPIMethod.php @@ -79,6 +79,7 @@ final class DiffusionQueryCommitsConduitAPIMethod 'repositoryPHID' => $commit->getRepository()->getPHID(), 'identifier' => $commit->getCommitIdentifier(), 'epoch' => $commit->getEpoch(), + 'authorEpoch' => $commit_data->getCommitDetail('authorEpoch'), 'uri' => $uri, 'isImporting' => !$commit->isImported(), 'summary' => $commit->getSummary(), @@ -99,6 +100,7 @@ final class DiffusionQueryCommitsConduitAPIMethod ->withIdentifier($commit->getCommitIdentifier()) ->execute(); + $dict['authorEpoch'] = $lowlevel_commitref->getAuthorEpoch(); $dict['author'] = $lowlevel_commitref->getAuthor(); $dict['authorName'] = $lowlevel_commitref->getAuthorName(); $dict['authorEmail'] = $lowlevel_commitref->getAuthorEmail(); diff --git a/src/applications/diffusion/controller/DiffusionCommitController.php b/src/applications/diffusion/controller/DiffusionCommitController.php index 2b0e589687..218a8e3d44 100644 --- a/src/applications/diffusion/controller/DiffusionCommitController.php +++ b/src/applications/diffusion/controller/DiffusionCommitController.php @@ -492,8 +492,12 @@ final class DiffusionCommitController extends DiffusionController { if (!$repository->isSVN()) { $authored_info = id(new PHUIStatusItemView()); - // TODO: In Git, a distinct authorship date is available. When present, - // we should show it here. + + $author_epoch = $data->getCommitDetail('authorEpoch'); + if ($author_epoch !== null) { + $authored_info->setNote( + phabricator_datetime($author_epoch, $viewer)); + } if ($author_phid) { $authored_info->setTarget($handles[$author_phid]->renderLink()); diff --git a/src/applications/diffusion/data/DiffusionCommitRef.php b/src/applications/diffusion/data/DiffusionCommitRef.php index a3b10c2764..373fdfaf0d 100644 --- a/src/applications/diffusion/data/DiffusionCommitRef.php +++ b/src/applications/diffusion/data/DiffusionCommitRef.php @@ -3,6 +3,7 @@ final class DiffusionCommitRef extends Phobject { private $message; + private $authorEpoch; private $authorName; private $authorEmail; private $committerName; @@ -11,6 +12,7 @@ final class DiffusionCommitRef extends Phobject { public static function newFromConduitResult(array $result) { $ref = id(new DiffusionCommitRef()) + ->setAuthorEpoch(idx($result, 'authorEpoch')) ->setCommitterEmail(idx($result, 'committerEmail')) ->setCommitterName(idx($result, 'committerName')) ->setAuthorEmail(idx($result, 'authorEmail')) @@ -38,6 +40,15 @@ final class DiffusionCommitRef extends Phobject { return $this->hashes; } + public function setAuthorEpoch($author_epoch) { + $this->authorEpoch = $author_epoch; + return $this; + } + + public function getAuthorEpoch() { + return $this->authorEpoch; + } + public function setCommitterEmail($committer_email) { $this->committerEmail = $committer_email; return $this; diff --git a/src/applications/diffusion/query/lowlevel/DiffusionLowLevelCommitQuery.php b/src/applications/diffusion/query/lowlevel/DiffusionLowLevelCommitQuery.php index 43862ce451..30a7b2e797 100644 --- a/src/applications/diffusion/query/lowlevel/DiffusionLowLevelCommitQuery.php +++ b/src/applications/diffusion/query/lowlevel/DiffusionLowLevelCommitQuery.php @@ -52,7 +52,7 @@ final class DiffusionLowLevelCommitQuery 'UTF-8', implode( '%x00', - array('%e', '%cn', '%ce', '%an', '%ae', '%T', '%s%n%n%b')), + array('%e', '%cn', '%ce', '%an', '%ae', '%T', '%at', '%s%n%n%b')), $this->identifier); $parts = explode("\0", $info); @@ -77,13 +77,19 @@ final class DiffusionLowLevelCommitQuery ->setHashValue($parts[4]), ); + $author_epoch = (int)$parts[5]; + if (!$author_epoch) { + $author_epoch = null; + } + return id(new DiffusionCommitRef()) ->setCommitterName($parts[0]) ->setCommitterEmail($parts[1]) ->setAuthorName($parts[2]) ->setAuthorEmail($parts[3]) ->setHashes($hashes) - ->setMessage($parts[5]); + ->setAuthorEpoch($author_epoch) + ->setMessage($parts[6]); } private function loadMercurialCommitRef() { diff --git a/src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php b/src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php index 17a2f3a3f2..dbb912eda4 100644 --- a/src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php +++ b/src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php @@ -58,6 +58,7 @@ abstract class PhabricatorRepositoryCommitMessageParserWorker ->setMaximumBytes(255) ->truncateString((string)$author)); + $data->setCommitDetail('authorEpoch', $ref->getAuthorEpoch()); $data->setCommitDetail('authorName', $ref->getAuthorName()); $data->setCommitDetail('authorEmail', $ref->getAuthorEmail());