mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 23:02:42 +01:00
Diffusion - move build refs to occur over Conduit
Summary: Ref T2784. Test Plan: loaded up a git commit with refs and they showed up! loaded up a git commit without revs and nothing showed up. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T2784 Differential Revision: https://secure.phabricator.com/D5957
This commit is contained in:
parent
2f44c0fac9
commit
07ad4d154c
3 changed files with 68 additions and 30 deletions
|
@ -157,6 +157,7 @@ phutil_register_library_map(array(
|
|||
'ConduitAPI_diffusion_getrecentcommitsbypath_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_getrecentcommitsbypath_Method.php',
|
||||
'ConduitAPI_diffusion_lastmodifiedquery_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_lastmodifiedquery_Method.php',
|
||||
'ConduitAPI_diffusion_rawdiffquery_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_rawdiffquery_Method.php',
|
||||
'ConduitAPI_diffusion_refsquery_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_refsquery_Method.php',
|
||||
'ConduitAPI_diffusion_searchquery_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_searchquery_Method.php',
|
||||
'ConduitAPI_diffusion_stablecommitnamequery_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_stablecommitnamequery_Method.php',
|
||||
'ConduitAPI_diffusion_tagsquery_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_tagsquery_Method.php',
|
||||
|
@ -1961,6 +1962,7 @@ phutil_register_library_map(array(
|
|||
'ConduitAPI_diffusion_getrecentcommitsbypath_Method' => 'ConduitAPI_diffusion_Method',
|
||||
'ConduitAPI_diffusion_lastmodifiedquery_Method' => 'ConduitAPI_diffusion_abstractquery_Method',
|
||||
'ConduitAPI_diffusion_rawdiffquery_Method' => 'ConduitAPI_diffusion_abstractquery_Method',
|
||||
'ConduitAPI_diffusion_refsquery_Method' => 'ConduitAPI_diffusion_abstractquery_Method',
|
||||
'ConduitAPI_diffusion_searchquery_Method' => 'ConduitAPI_diffusion_abstractquery_Method',
|
||||
'ConduitAPI_diffusion_stablecommitnamequery_Method' => 'ConduitAPI_diffusion_abstractquery_Method',
|
||||
'ConduitAPI_diffusion_tagsquery_Method' => 'ConduitAPI_diffusion_abstractquery_Method',
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @group conduit
|
||||
*/
|
||||
final class ConduitAPI_diffusion_refsquery_Method
|
||||
extends ConduitAPI_diffusion_abstractquery_Method {
|
||||
|
||||
public function getMethodDescription() {
|
||||
return
|
||||
'Query a git repository for ref information at a specific commit.';
|
||||
}
|
||||
|
||||
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($stdout) = $repository->execxLocalCommand(
|
||||
'log --format=%s -n 1 %s --',
|
||||
'%d',
|
||||
$commit);
|
||||
|
||||
// %d, gives a weird output format
|
||||
// similar to (remote/one, remote/two, remote/three)
|
||||
$refs = trim($stdout, "() \n");
|
||||
if (!$refs) {
|
||||
return null;
|
||||
}
|
||||
$refs = explode(',', $refs);
|
||||
$refs = array_map('trim', $refs);
|
||||
|
||||
$ref_links = array();
|
||||
foreach ($refs as $ref) {
|
||||
$ref_links[] = array(
|
||||
'ref' => $ref,
|
||||
'href' => $drequest->generateURI(
|
||||
array(
|
||||
'action' => 'browse',
|
||||
'branch' => $ref,
|
||||
)));
|
||||
}
|
||||
|
||||
return $ref_links;
|
||||
}
|
||||
|
||||
}
|
|
@ -902,44 +902,23 @@ final class DiffusionCommitController extends DiffusionController {
|
|||
}
|
||||
|
||||
private function buildRefs(DiffusionRequest $request) {
|
||||
// Not turning this into a proper Query class since it's pretty simple,
|
||||
// one-off, and Git-specific.
|
||||
|
||||
// this is git-only, so save a conduit round trip and just get out of
|
||||
// here if the repository isn't git
|
||||
$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());
|
||||
|
||||
// %d, gives a weird output format
|
||||
// similar to (remote/one, remote/two, remote/three)
|
||||
$refs = trim($stdout, "() \n");
|
||||
if (!$refs) {
|
||||
return null;
|
||||
}
|
||||
$refs = explode(',', $refs);
|
||||
$refs = array_map('trim', $refs);
|
||||
|
||||
$results = $this->callConduitWithDiffusionRequest(
|
||||
'diffusion.refsquery',
|
||||
array('commit' => $request->getCommit()));
|
||||
$ref_links = array();
|
||||
foreach ($refs as $ref) {
|
||||
$ref_links[] = phutil_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => $request->generateURI(
|
||||
array(
|
||||
'action' => 'browse',
|
||||
'branch' => $ref,
|
||||
)),
|
||||
),
|
||||
$ref);
|
||||
foreach ($results as $ref_data) {
|
||||
$ref_links[] = phutil_tag('a',
|
||||
array('href' => $ref_data['href']),
|
||||
$ref_data['ref']);
|
||||
}
|
||||
|
||||
return phutil_implode_html(', ', $ref_links);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue