Page MenuHomeDevCentral

Get authored date on Diffusion for Git commits (kludge)
ActivePublic

Authored by dereckson on Jul 11 2015, 20:20.
From d5aa1df97553d678c69139fbbab6d2667bb7d602 Mon Sep 17 00:00:00 2001
From: Nasqueron Operations <ops-noreply@nasqueron.org>
Date: Sat, 11 Jul 2015 20:16:44 +0000
Subject: [PATCH] Kludge to get commit authored date
---
.../diffusion/controller/DiffusionCommitController.php | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/src/applications/diffusion/controller/DiffusionCommitController.php b/src/applications/diffusion/controller/DiffusionCommitController.php
index 74441be..f0bd340 100644
--- a/src/applications/diffusion/controller/DiffusionCommitController.php
+++ b/src/applications/diffusion/controller/DiffusionCommitController.php
@@ -523,13 +523,25 @@ final class DiffusionCommitController extends DiffusionController {
}
}
+ $commit_epoch = $commit->getEpoch();
+
$author_phid = $data->getCommitDetail('authorPHID');
$author_name = $data->getAuthorName();
if (!$repository->isSVN()) {
+ if ($repository->isGit()) {
+ $path = $repository->getDetails()['local-path'];
+ $commitIdentifier = $commit->getCommitIdentifier();
+ $authored_epoch = `cd $path ; git show -s --format="%at" $commitIdentifier`;
+ } else {
+ $authored_epoch = null;
+ }
+
$authored_info = id(new PHUIStatusItemView());
- // TODO: In Git, a distinct authorship date is available. When present,
- // we should show it here.
+ if ($authored_epoch && abs($authored_epoch - $commit_epoch) > 59) {
+ $authored_info
+ ->setNote(phabricator_datetime($authored_epoch, $viewer));
+ }
if ($author_phid) {
$authored_info->setTarget($handles[$author_phid]->renderLink());
--
2.1.1

Event Timeline

dereckson changed the title of this paste from untitled to Get authored date on Diffusion for Git commits (kludge).
dereckson updated the paste's language from autodetect to php.
dereckson added a project: DevCentral.