From 4edf8ae2fcb91d220a816189f5d9f4d762aec0f7 Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Wed, 31 Oct 2012 14:07:25 -0700 Subject: [PATCH] make "browse in diffusion" action work for commits in branches other than master Summary: we do this by passing the "seenOnBranches" commit data detail through the stack Test Plan: browse in diffusion link worked for non-master checkins under git Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T1949 Differential Revision: https://secure.phabricator.com/D3853 --- .../view/DifferentialChangesetListView.php | 12 +++++++++++- .../controller/DiffusionCommitController.php | 4 ++++ .../repository/storage/PhabricatorRepository.php | 5 ++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/applications/differential/view/DifferentialChangesetListView.php b/src/applications/differential/view/DifferentialChangesetListView.php index 3f9cfe8e13..8a200317bb 100644 --- a/src/applications/differential/view/DifferentialChangesetListView.php +++ b/src/applications/differential/view/DifferentialChangesetListView.php @@ -32,9 +32,18 @@ final class DifferentialChangesetListView extends AphrontView { private $user; private $symbolIndexes = array(); private $repository; + private $branch; private $diff; private $vsMap = array(); + public function setBranch($branch) { + $this->branch = $branch; + return $this; + } + private function getBranch() { + return $this->branch; + } + public function setChangesets($changesets) { $this->changesets = $changesets; return $this; @@ -257,7 +266,8 @@ final class DifferentialChangesetListView extends AphrontView { if ($repository) { $meta['diffusionURI'] = (string)$repository->getDiffusionBrowseURIForPath( $changeset->getAbsoluteRepositoryPath($repository, $this->diff), - idx($changeset->getMetadata(), 'line:first')); + idx($changeset->getMetadata(), 'line:first'), + $this->getBranch()); } $change = $changeset->getChangeType(); diff --git a/src/applications/diffusion/controller/DiffusionCommitController.php b/src/applications/diffusion/controller/DiffusionCommitController.php index b9fe53ed84..353d48f245 100644 --- a/src/applications/diffusion/controller/DiffusionCommitController.php +++ b/src/applications/diffusion/controller/DiffusionCommitController.php @@ -269,6 +269,10 @@ final class DiffusionCommitController extends DiffusionController { $change_list->setRenderURI('/diffusion/'.$callsign.'/diff/'); $change_list->setRepository($repository); $change_list->setUser($user); + // pick the first branch for "Browse in Diffusion" View Option + $branches = $commit_data->getCommitDetail('seenOnBranches'); + $first_branch = reset($branches); + $change_list->setBranch($first_branch); $change_list->setStandaloneURI( '/diffusion/'.$callsign.'/diff/'); diff --git a/src/applications/repository/storage/PhabricatorRepository.php b/src/applications/repository/storage/PhabricatorRepository.php index fa158f6579..e0930a8155 100644 --- a/src/applications/repository/storage/PhabricatorRepository.php +++ b/src/applications/repository/storage/PhabricatorRepository.php @@ -60,11 +60,14 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO { return $this; } - public function getDiffusionBrowseURIForPath($path, $line = null) { + public function getDiffusionBrowseURIForPath($path, + $line = null, + $branch = null) { $drequest = DiffusionRequest::newFromDictionary( array( 'repository' => $this, 'path' => $path, + 'branch' => $branch, )); return $drequest->generateURI(