From 284ee03919b356e1ee8d22561916ddaad9ab765b Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 25 Apr 2012 07:21:03 -0700 Subject: [PATCH] Show refs in Diffusion for Git commits Summary: In Diffusion, for Git, show commit refs (like "origin/master, origin/HEAD"). Test Plan: Looked at several Git, Hg and SVN commits. Reviewers: davidreuss, btrahan, vrana, jungejason Reviewed By: btrahan CC: aran Maniphest Tasks: T1130 Differential Revision: https://secure.phabricator.com/D2311 --- .../commit/DiffusionCommitController.php | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/applications/diffusion/controller/commit/DiffusionCommitController.php b/src/applications/diffusion/controller/commit/DiffusionCommitController.php index 0d721b0f16..b9346efb64 100644 --- a/src/applications/diffusion/controller/commit/DiffusionCommitController.php +++ b/src/applications/diffusion/controller/commit/DiffusionCommitController.php @@ -352,11 +352,16 @@ final class DiffusionCommitController extends DiffusionController { } - $tags = $this->renderTags($request); + $tags = $this->buildTags($request); if ($tags) { $props['Tags'] = $tags; } + $refs = $this->buildRefs($request); + if ($refs) { + $props['Refs'] = $refs; + } + if ($task_phids) { $task_list = array(); foreach ($task_phids as $phid) { @@ -726,7 +731,7 @@ final class DiffusionCommitController extends DiffusionController { return $action_list; } - private function renderTags(DiffusionRequest $request) { + private function buildTags(DiffusionRequest $request) { $tag_limit = 10; $tag_query = DiffusionCommitTagsQuery::newFromDiffusionRequest($request); @@ -771,4 +776,23 @@ final class DiffusionCommitController extends DiffusionController { return $tag_links; } + private function buildRefs(DiffusionRequest $request) { + // Not turning this into a proper Query class since it's pretty simple, + // one-off, and Git-specific. + + $type_git = PhabricatorRepositoryType::REPOSITORY_TYPE_GIT; + + $repository = $request->getRepository(); + if ($repository->getVersionControlSystem() != $type_git) { + return null; + } + + list($stdout) = $repository->execxLocalCommand( + 'log --format=%s -n 1 %s --', + '%d', + $request->getCommit()); + + return trim($stdout, "() \n"); + } + }