mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 16:52:41 +01:00
Diffusion - move commit branches query to conduit
Summary: Ref T2784. Test Plan: loaded up a mercurial and a git commit. verified branches showed up correctly in object detail panel Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T2784 Differential Revision: https://secure.phabricator.com/D5958
This commit is contained in:
parent
f2efda75b5
commit
0212d75632
7 changed files with 57 additions and 70 deletions
|
@ -147,6 +147,7 @@ phutil_register_library_map(array(
|
||||||
'ConduitAPI_diffusion_abstractquery_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_abstractquery_Method.php',
|
'ConduitAPI_diffusion_abstractquery_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_abstractquery_Method.php',
|
||||||
'ConduitAPI_diffusion_branchquery_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_branchquery_Method.php',
|
'ConduitAPI_diffusion_branchquery_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_branchquery_Method.php',
|
||||||
'ConduitAPI_diffusion_browsequery_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_browsequery_Method.php',
|
'ConduitAPI_diffusion_browsequery_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_browsequery_Method.php',
|
||||||
|
'ConduitAPI_diffusion_commitbranchesquery_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_commitbranchesquery_Method.php',
|
||||||
'ConduitAPI_diffusion_diffquery_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_diffquery_Method.php',
|
'ConduitAPI_diffusion_diffquery_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_diffquery_Method.php',
|
||||||
'ConduitAPI_diffusion_existsquery_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_existsquery_Method.php',
|
'ConduitAPI_diffusion_existsquery_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_existsquery_Method.php',
|
||||||
'ConduitAPI_diffusion_expandshortcommitquery_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_expandshortcommitquery_Method.php',
|
'ConduitAPI_diffusion_expandshortcommitquery_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_expandshortcommitquery_Method.php',
|
||||||
|
@ -429,7 +430,6 @@ phutil_register_library_map(array(
|
||||||
'DiffusionCommitParentsQuery' => 'applications/diffusion/query/parents/DiffusionCommitParentsQuery.php',
|
'DiffusionCommitParentsQuery' => 'applications/diffusion/query/parents/DiffusionCommitParentsQuery.php',
|
||||||
'DiffusionCommitQuery' => 'applications/diffusion/query/DiffusionCommitQuery.php',
|
'DiffusionCommitQuery' => 'applications/diffusion/query/DiffusionCommitQuery.php',
|
||||||
'DiffusionCommitTagsController' => 'applications/diffusion/controller/DiffusionCommitTagsController.php',
|
'DiffusionCommitTagsController' => 'applications/diffusion/controller/DiffusionCommitTagsController.php',
|
||||||
'DiffusionContainsQuery' => 'applications/diffusion/query/contains/DiffusionContainsQuery.php',
|
|
||||||
'DiffusionController' => 'applications/diffusion/controller/DiffusionController.php',
|
'DiffusionController' => 'applications/diffusion/controller/DiffusionController.php',
|
||||||
'DiffusionDiffController' => 'applications/diffusion/controller/DiffusionDiffController.php',
|
'DiffusionDiffController' => 'applications/diffusion/controller/DiffusionDiffController.php',
|
||||||
'DiffusionEmptyResultView' => 'applications/diffusion/view/DiffusionEmptyResultView.php',
|
'DiffusionEmptyResultView' => 'applications/diffusion/view/DiffusionEmptyResultView.php',
|
||||||
|
@ -441,7 +441,6 @@ phutil_register_library_map(array(
|
||||||
'DiffusionGitBranch' => 'applications/diffusion/data/DiffusionGitBranch.php',
|
'DiffusionGitBranch' => 'applications/diffusion/data/DiffusionGitBranch.php',
|
||||||
'DiffusionGitBranchTestCase' => 'applications/diffusion/data/__tests__/DiffusionGitBranchTestCase.php',
|
'DiffusionGitBranchTestCase' => 'applications/diffusion/data/__tests__/DiffusionGitBranchTestCase.php',
|
||||||
'DiffusionGitCommitParentsQuery' => 'applications/diffusion/query/parents/DiffusionGitCommitParentsQuery.php',
|
'DiffusionGitCommitParentsQuery' => 'applications/diffusion/query/parents/DiffusionGitCommitParentsQuery.php',
|
||||||
'DiffusionGitContainsQuery' => 'applications/diffusion/query/contains/DiffusionGitContainsQuery.php',
|
|
||||||
'DiffusionGitExpandShortNameQuery' => 'applications/diffusion/query/expandshortname/DiffusionGitExpandShortNameQuery.php',
|
'DiffusionGitExpandShortNameQuery' => 'applications/diffusion/query/expandshortname/DiffusionGitExpandShortNameQuery.php',
|
||||||
'DiffusionGitFileContentQuery' => 'applications/diffusion/query/filecontent/DiffusionGitFileContentQuery.php',
|
'DiffusionGitFileContentQuery' => 'applications/diffusion/query/filecontent/DiffusionGitFileContentQuery.php',
|
||||||
'DiffusionGitHistoryQuery' => 'applications/diffusion/query/history/DiffusionGitHistoryQuery.php',
|
'DiffusionGitHistoryQuery' => 'applications/diffusion/query/history/DiffusionGitHistoryQuery.php',
|
||||||
|
@ -461,7 +460,6 @@ phutil_register_library_map(array(
|
||||||
'DiffusionLintDetailsController' => 'applications/diffusion/controller/DiffusionLintDetailsController.php',
|
'DiffusionLintDetailsController' => 'applications/diffusion/controller/DiffusionLintDetailsController.php',
|
||||||
'DiffusionLintSaveRunner' => 'applications/diffusion/DiffusionLintSaveRunner.php',
|
'DiffusionLintSaveRunner' => 'applications/diffusion/DiffusionLintSaveRunner.php',
|
||||||
'DiffusionMercurialCommitParentsQuery' => 'applications/diffusion/query/parents/DiffusionMercurialCommitParentsQuery.php',
|
'DiffusionMercurialCommitParentsQuery' => 'applications/diffusion/query/parents/DiffusionMercurialCommitParentsQuery.php',
|
||||||
'DiffusionMercurialContainsQuery' => 'applications/diffusion/query/contains/DiffusionMercurialContainsQuery.php',
|
|
||||||
'DiffusionMercurialExpandShortNameQuery' => 'applications/diffusion/query/expandshortname/DiffusionMercurialExpandShortNameQuery.php',
|
'DiffusionMercurialExpandShortNameQuery' => 'applications/diffusion/query/expandshortname/DiffusionMercurialExpandShortNameQuery.php',
|
||||||
'DiffusionMercurialFileContentQuery' => 'applications/diffusion/query/filecontent/DiffusionMercurialFileContentQuery.php',
|
'DiffusionMercurialFileContentQuery' => 'applications/diffusion/query/filecontent/DiffusionMercurialFileContentQuery.php',
|
||||||
'DiffusionMercurialHistoryQuery' => 'applications/diffusion/query/history/DiffusionMercurialHistoryQuery.php',
|
'DiffusionMercurialHistoryQuery' => 'applications/diffusion/query/history/DiffusionMercurialHistoryQuery.php',
|
||||||
|
@ -489,7 +487,6 @@ phutil_register_library_map(array(
|
||||||
'DiffusionSetupException' => 'applications/diffusion/exception/DiffusionSetupException.php',
|
'DiffusionSetupException' => 'applications/diffusion/exception/DiffusionSetupException.php',
|
||||||
'DiffusionStableCommitNameQuery' => 'applications/diffusion/query/stablecommitname/DiffusionStableCommitNameQuery.php',
|
'DiffusionStableCommitNameQuery' => 'applications/diffusion/query/stablecommitname/DiffusionStableCommitNameQuery.php',
|
||||||
'DiffusionSvnCommitParentsQuery' => 'applications/diffusion/query/parents/DiffusionSvnCommitParentsQuery.php',
|
'DiffusionSvnCommitParentsQuery' => 'applications/diffusion/query/parents/DiffusionSvnCommitParentsQuery.php',
|
||||||
'DiffusionSvnContainsQuery' => 'applications/diffusion/query/contains/DiffusionSvnContainsQuery.php',
|
|
||||||
'DiffusionSvnFileContentQuery' => 'applications/diffusion/query/filecontent/DiffusionSvnFileContentQuery.php',
|
'DiffusionSvnFileContentQuery' => 'applications/diffusion/query/filecontent/DiffusionSvnFileContentQuery.php',
|
||||||
'DiffusionSvnHistoryQuery' => 'applications/diffusion/query/history/DiffusionSvnHistoryQuery.php',
|
'DiffusionSvnHistoryQuery' => 'applications/diffusion/query/history/DiffusionSvnHistoryQuery.php',
|
||||||
'DiffusionSvnMergedCommitsQuery' => 'applications/diffusion/query/mergedcommits/DiffusionSvnMergedCommitsQuery.php',
|
'DiffusionSvnMergedCommitsQuery' => 'applications/diffusion/query/mergedcommits/DiffusionSvnMergedCommitsQuery.php',
|
||||||
|
@ -1952,6 +1949,7 @@ phutil_register_library_map(array(
|
||||||
'ConduitAPI_diffusion_abstractquery_Method' => 'ConduitAPI_diffusion_Method',
|
'ConduitAPI_diffusion_abstractquery_Method' => 'ConduitAPI_diffusion_Method',
|
||||||
'ConduitAPI_diffusion_branchquery_Method' => 'ConduitAPI_diffusion_abstractquery_Method',
|
'ConduitAPI_diffusion_branchquery_Method' => 'ConduitAPI_diffusion_abstractquery_Method',
|
||||||
'ConduitAPI_diffusion_browsequery_Method' => 'ConduitAPI_diffusion_abstractquery_Method',
|
'ConduitAPI_diffusion_browsequery_Method' => 'ConduitAPI_diffusion_abstractquery_Method',
|
||||||
|
'ConduitAPI_diffusion_commitbranchesquery_Method' => 'ConduitAPI_diffusion_abstractquery_Method',
|
||||||
'ConduitAPI_diffusion_diffquery_Method' => 'ConduitAPI_diffusion_abstractquery_Method',
|
'ConduitAPI_diffusion_diffquery_Method' => 'ConduitAPI_diffusion_abstractquery_Method',
|
||||||
'ConduitAPI_diffusion_existsquery_Method' => 'ConduitAPI_diffusion_abstractquery_Method',
|
'ConduitAPI_diffusion_existsquery_Method' => 'ConduitAPI_diffusion_abstractquery_Method',
|
||||||
'ConduitAPI_diffusion_expandshortcommitquery_Method' => 'ConduitAPI_diffusion_abstractquery_Method',
|
'ConduitAPI_diffusion_expandshortcommitquery_Method' => 'ConduitAPI_diffusion_abstractquery_Method',
|
||||||
|
@ -2224,7 +2222,6 @@ phutil_register_library_map(array(
|
||||||
'DiffusionCommitParentsQuery' => 'DiffusionQuery',
|
'DiffusionCommitParentsQuery' => 'DiffusionQuery',
|
||||||
'DiffusionCommitQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
'DiffusionCommitQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||||
'DiffusionCommitTagsController' => 'DiffusionController',
|
'DiffusionCommitTagsController' => 'DiffusionController',
|
||||||
'DiffusionContainsQuery' => 'DiffusionQuery',
|
|
||||||
'DiffusionController' => 'PhabricatorController',
|
'DiffusionController' => 'PhabricatorController',
|
||||||
'DiffusionDiffController' => 'DiffusionController',
|
'DiffusionDiffController' => 'DiffusionController',
|
||||||
'DiffusionEmptyResultView' => 'DiffusionView',
|
'DiffusionEmptyResultView' => 'DiffusionView',
|
||||||
|
@ -2234,7 +2231,6 @@ phutil_register_library_map(array(
|
||||||
'DiffusionFileContentQuery' => 'DiffusionQuery',
|
'DiffusionFileContentQuery' => 'DiffusionQuery',
|
||||||
'DiffusionGitBranchTestCase' => 'PhabricatorTestCase',
|
'DiffusionGitBranchTestCase' => 'PhabricatorTestCase',
|
||||||
'DiffusionGitCommitParentsQuery' => 'DiffusionCommitParentsQuery',
|
'DiffusionGitCommitParentsQuery' => 'DiffusionCommitParentsQuery',
|
||||||
'DiffusionGitContainsQuery' => 'DiffusionContainsQuery',
|
|
||||||
'DiffusionGitExpandShortNameQuery' => 'DiffusionExpandShortNameQuery',
|
'DiffusionGitExpandShortNameQuery' => 'DiffusionExpandShortNameQuery',
|
||||||
'DiffusionGitFileContentQuery' => 'DiffusionFileContentQuery',
|
'DiffusionGitFileContentQuery' => 'DiffusionFileContentQuery',
|
||||||
'DiffusionGitHistoryQuery' => 'DiffusionHistoryQuery',
|
'DiffusionGitHistoryQuery' => 'DiffusionHistoryQuery',
|
||||||
|
@ -2253,7 +2249,6 @@ phutil_register_library_map(array(
|
||||||
'DiffusionLintController' => 'DiffusionController',
|
'DiffusionLintController' => 'DiffusionController',
|
||||||
'DiffusionLintDetailsController' => 'DiffusionController',
|
'DiffusionLintDetailsController' => 'DiffusionController',
|
||||||
'DiffusionMercurialCommitParentsQuery' => 'DiffusionCommitParentsQuery',
|
'DiffusionMercurialCommitParentsQuery' => 'DiffusionCommitParentsQuery',
|
||||||
'DiffusionMercurialContainsQuery' => 'DiffusionContainsQuery',
|
|
||||||
'DiffusionMercurialExpandShortNameQuery' => 'DiffusionExpandShortNameQuery',
|
'DiffusionMercurialExpandShortNameQuery' => 'DiffusionExpandShortNameQuery',
|
||||||
'DiffusionMercurialFileContentQuery' => 'DiffusionFileContentQuery',
|
'DiffusionMercurialFileContentQuery' => 'DiffusionFileContentQuery',
|
||||||
'DiffusionMercurialHistoryQuery' => 'DiffusionHistoryQuery',
|
'DiffusionMercurialHistoryQuery' => 'DiffusionHistoryQuery',
|
||||||
|
@ -2273,7 +2268,6 @@ phutil_register_library_map(array(
|
||||||
'DiffusionSetupException' => 'AphrontUsageException',
|
'DiffusionSetupException' => 'AphrontUsageException',
|
||||||
'DiffusionStableCommitNameQuery' => 'DiffusionQuery',
|
'DiffusionStableCommitNameQuery' => 'DiffusionQuery',
|
||||||
'DiffusionSvnCommitParentsQuery' => 'DiffusionCommitParentsQuery',
|
'DiffusionSvnCommitParentsQuery' => 'DiffusionCommitParentsQuery',
|
||||||
'DiffusionSvnContainsQuery' => 'DiffusionContainsQuery',
|
|
||||||
'DiffusionSvnFileContentQuery' => 'DiffusionFileContentQuery',
|
'DiffusionSvnFileContentQuery' => 'DiffusionFileContentQuery',
|
||||||
'DiffusionSvnHistoryQuery' => 'DiffusionHistoryQuery',
|
'DiffusionSvnHistoryQuery' => 'DiffusionHistoryQuery',
|
||||||
'DiffusionSvnMergedCommitsQuery' => 'DiffusionMergedCommitsQuery',
|
'DiffusionSvnMergedCommitsQuery' => 'DiffusionMergedCommitsQuery',
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group conduit
|
||||||
|
*/
|
||||||
|
final class ConduitAPI_diffusion_commitbranchesquery_Method
|
||||||
|
extends ConduitAPI_diffusion_abstractquery_Method {
|
||||||
|
|
||||||
|
public function getMethodDescription() {
|
||||||
|
return 'Determine what branches contain a commit in a repository.';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function defineReturnType() {
|
||||||
|
return 'array';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function defineCustomParamTypes() {
|
||||||
|
return array(
|
||||||
|
'commit' => 'required string',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getGitResult(ConduitAPIRequest $request) {
|
||||||
|
$drequest = $this->getDiffusionRequest();
|
||||||
|
$repository = $drequest->getRepository();
|
||||||
|
$commit = $request->getValue('commit');
|
||||||
|
|
||||||
|
list($contains) = $repository->execxLocalCommand(
|
||||||
|
'branch -r --verbose --no-abbrev --contains %s',
|
||||||
|
$commit);
|
||||||
|
|
||||||
|
return DiffusionGitBranch::parseRemoteBranchOutput(
|
||||||
|
$contains,
|
||||||
|
DiffusionBranchInformation::DEFAULT_GIT_REMOTE);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getMercurialResult(ConduitAPIRequest $request) {
|
||||||
|
$drequest = $this->getDiffusionRequest();
|
||||||
|
$repository = $drequest->getRepository();
|
||||||
|
$commit = $request->getValue('commit');
|
||||||
|
|
||||||
|
list($contains) = $repository->execxLocalCommand(
|
||||||
|
'log --template %s --limit 1 --rev %s --',
|
||||||
|
'{branch}',
|
||||||
|
$commit);
|
||||||
|
|
||||||
|
return array(
|
||||||
|
trim($contains) => $commit,
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,8 +10,9 @@ final class DiffusionCommitBranchesController extends DiffusionController {
|
||||||
public function processRequest() {
|
public function processRequest() {
|
||||||
$request = $this->getDiffusionRequest();
|
$request = $this->getDiffusionRequest();
|
||||||
|
|
||||||
$branch_query = DiffusionContainsQuery::newFromDiffusionRequest($request);
|
$branches = $this->callConduitWithDiffusionRequest(
|
||||||
$branches = $branch_query->loadContainingBranches();
|
'diffusion.commitbranchesquery',
|
||||||
|
array('commit' => $request->getCommit()));
|
||||||
|
|
||||||
$branch_links = array();
|
$branch_links = array();
|
||||||
foreach ($branches as $branch => $commit) {
|
foreach ($branches as $branch => $commit) {
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
abstract class DiffusionContainsQuery extends DiffusionQuery {
|
|
||||||
|
|
||||||
final public static function newFromDiffusionRequest(
|
|
||||||
DiffusionRequest $request) {
|
|
||||||
return self::newQueryObject(__CLASS__, $request);
|
|
||||||
}
|
|
||||||
|
|
||||||
final public function loadContainingBranches() {
|
|
||||||
return $this->executeQuery();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
final class DiffusionGitContainsQuery extends DiffusionContainsQuery {
|
|
||||||
|
|
||||||
final public function executeQuery() {
|
|
||||||
$request = $this->getRequest();
|
|
||||||
$repository = $request->getRepository();
|
|
||||||
|
|
||||||
list($contains) = $repository->execxLocalCommand(
|
|
||||||
'branch -r --verbose --no-abbrev --contains %s',
|
|
||||||
$request->getCommit());
|
|
||||||
|
|
||||||
return DiffusionGitBranch::parseRemoteBranchOutput(
|
|
||||||
$contains,
|
|
||||||
DiffusionBranchInformation::DEFAULT_GIT_REMOTE);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
final class DiffusionMercurialContainsQuery extends DiffusionContainsQuery {
|
|
||||||
|
|
||||||
protected function executeQuery() {
|
|
||||||
$request = $this->getRequest();
|
|
||||||
$repository = $request->getRepository();
|
|
||||||
list($contains) = $repository->execxLocalCommand(
|
|
||||||
'log --template %s --limit 1 --rev %s --',
|
|
||||||
'{branch}',
|
|
||||||
$request->getCommit());
|
|
||||||
|
|
||||||
return array(
|
|
||||||
trim($contains) => $request->getCommit(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
final class DiffusionSvnContainsQuery extends DiffusionContainsQuery {
|
|
||||||
|
|
||||||
protected function executeQuery() {
|
|
||||||
// NOTE: Subversion doesn't have branches, so we always return empty.
|
|
||||||
return array();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in a new issue