1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 05:50:55 +01:00

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
This commit is contained in:
epriestley 2012-04-25 07:21:03 -07:00
parent 0732f2f9dd
commit 284ee03919

View file

@ -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");
}
}