Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/diffusion/conduit/DiffusionInternalAncestorsConduitAPIMethod.php
12242 views
1
<?php
2
3
final class DiffusionInternalAncestorsConduitAPIMethod
4
extends DiffusionQueryConduitAPIMethod {
5
6
public function isInternalAPI() {
7
return true;
8
}
9
10
public function getAPIMethodName() {
11
return 'diffusion.internal.ancestors';
12
}
13
14
public function getMethodDescription() {
15
return pht('Internal method for filtering ref ancestors.');
16
}
17
18
protected function defineReturnType() {
19
return 'list<string>';
20
}
21
22
protected function defineCustomParamTypes() {
23
return array(
24
'ref' => 'required string',
25
'commits' => 'required list<string>',
26
);
27
}
28
29
protected function getResult(ConduitAPIRequest $request) {
30
$drequest = $this->getDiffusionRequest();
31
$repository = $drequest->getRepository();
32
33
$commits = $request->getValue('commits');
34
$ref = $request->getValue('ref');
35
36
$graph = new PhabricatorGitGraphStream($repository, $ref);
37
38
$keep = array();
39
foreach ($commits as $identifier) {
40
try {
41
$graph->getCommitDate($identifier);
42
$keep[] = $identifier;
43
} catch (Exception $ex) {
44
// Not an ancestor.
45
}
46
}
47
48
return $keep;
49
}
50
51
}
52
53