1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-04-04 16:38:24 +02:00

Fix the "Browse in Diffusion" URI in Differential

Summary: Apparently I spent like a good month copy/pasting slightly different versions of this logic all over the codebase.

Test Plan: Selected "View Options -> Browse in Diffusion" for a chagneset, got a URI with a branch name in it under Git.

Reviewers: vrana, btrahan

Reviewed By: btrahan

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D1993
This commit is contained in:
epriestley 2012-03-22 13:55:35 -07:00
parent e2a457873e
commit 85f19e16dc
3 changed files with 11 additions and 13 deletions

View file

@ -227,7 +227,7 @@ final class DifferentialChangesetListView extends AphrontView {
$repository = $this->repository; $repository = $this->repository;
if ($repository) { if ($repository) {
$meta['diffusionURI'] = $repository->getDiffusionBrowseURIForPath( $meta['diffusionURI'] = (string)$repository->getDiffusionBrowseURIForPath(
$changeset->getAbsoluteRepositoryPath($this->diff, $repository)); $changeset->getAbsoluteRepositoryPath($this->diff, $repository));
} }

View file

@ -58,19 +58,16 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO {
} }
public function getDiffusionBrowseURIForPath($path) { public function getDiffusionBrowseURIForPath($path) {
switch ($this->getVersionControlSystem()) { $drequest = DiffusionRequest::newFromDictionary(
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT: array(
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL: 'repository' => $this,
$branch = '/'.$this->getDetail('default-branch'); 'path' => $path,
break; ));
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
$branch = null;
break;
default:
throw new Exception("Unknown VCS.");
}
return '/diffusion/'.$this->getCallsign().'/browse'.$branch.$path; return $drequest->generateURI(
array(
'action' => 'browse',
));
} }
public static function newPhutilURIFromGitURI($raw_uri) { public static function newPhutilURIFromGitURI($raw_uri) {

View file

@ -6,6 +6,7 @@
phutil_require_module('phabricator', 'applications/diffusion/request/base');
phutil_require_module('phabricator', 'applications/phid/constants'); phutil_require_module('phabricator', 'applications/phid/constants');
phutil_require_module('phabricator', 'applications/phid/storage/phid'); phutil_require_module('phabricator', 'applications/phid/storage/phid');
phutil_require_module('phabricator', 'applications/repository/constants/repositorytype'); phutil_require_module('phabricator', 'applications/repository/constants/repositorytype');