1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-03-29 12:38:12 +01: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;
if ($repository) {
$meta['diffusionURI'] = $repository->getDiffusionBrowseURIForPath(
$meta['diffusionURI'] = (string)$repository->getDiffusionBrowseURIForPath(
$changeset->getAbsoluteRepositoryPath($this->diff, $repository));
}

View file

@ -58,19 +58,16 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO {
}
public function getDiffusionBrowseURIForPath($path) {
switch ($this->getVersionControlSystem()) {
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
$branch = '/'.$this->getDetail('default-branch');
break;
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
$branch = null;
break;
default:
throw new Exception("Unknown VCS.");
}
$drequest = DiffusionRequest::newFromDictionary(
array(
'repository' => $this,
'path' => $path,
));
return '/diffusion/'.$this->getCallsign().'/browse'.$branch.$path;
return $drequest->generateURI(
array(
'action' => 'browse',
));
}
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/storage/phid');
phutil_require_module('phabricator', 'applications/repository/constants/repositorytype');