mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-01 03:02:43 +01:00
156b156e77
Summary: Ref T7803. Ref T5873. I want to drive Conduit through more shared infrastructure, but can't currently add parameters automatically. Put a `getX()` around the `defineX()` methods so the parent can provide default behaviors. Also like 60% of methods don't define any special error types; don't require them to implement this method. I want to move away from this in general. Test Plan: - Ran `arc unit --everything`. - Called `conduit.query`. - Browsed Conduit UI. Reviewers: btrahan Reviewed By: btrahan Subscribers: hach-que, epriestley Maniphest Tasks: T5873, T7803 Differential Revision: https://secure.phabricator.com/D12380
59 lines
1.3 KiB
PHP
59 lines
1.3 KiB
PHP
<?php
|
|
|
|
final class DiffusionRefsQueryConduitAPIMethod
|
|
extends DiffusionQueryConduitAPIMethod {
|
|
|
|
public function getAPIMethodName() {
|
|
return 'diffusion.refsquery';
|
|
}
|
|
|
|
public function getMethodDescription() {
|
|
return
|
|
'Query a git repository for ref information at a specific commit.';
|
|
}
|
|
|
|
protected 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 array();
|
|
}
|
|
$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;
|
|
}
|
|
|
|
}
|