Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/diffusion/conduit/DiffusionGetRecentCommitsByPathConduitAPIMethod.php
12242 views
1
<?php
2
3
final class DiffusionGetRecentCommitsByPathConduitAPIMethod
4
extends DiffusionConduitAPIMethod {
5
6
const DEFAULT_LIMIT = 10;
7
8
public function getAPIMethodName() {
9
return 'diffusion.getrecentcommitsbypath';
10
}
11
12
public function getMethodStatus() {
13
return self::METHOD_STATUS_DEPRECATED;
14
}
15
16
public function getMethodStatusDescription() {
17
return pht('Obsoleted by "diffusion.historyquery".');
18
}
19
20
public function getMethodDescription() {
21
return pht(
22
'Get commit identifiers for recent commits affecting a given path.');
23
}
24
25
protected function defineParamTypes() {
26
return array(
27
'callsign' => 'required string',
28
'path' => 'required string',
29
'branch' => 'optional string',
30
'limit' => 'optional int',
31
);
32
}
33
34
protected function defineErrorTypes() {
35
return array(
36
'ERR_NOT_FOUND' => pht('Repository was not found.'),
37
);
38
}
39
40
protected function defineReturnType() {
41
return 'nonempty list<string>';
42
}
43
44
protected function execute(ConduitAPIRequest $request) {
45
$drequest = DiffusionRequest::newFromDictionary(
46
array(
47
'user' => $request->getUser(),
48
'callsign' => $request->getValue('callsign'),
49
'path' => $request->getValue('path'),
50
'branch' => $request->getValue('branch'),
51
));
52
53
if ($drequest === null) {
54
throw new ConduitException('ERR_NOT_FOUND');
55
}
56
57
$limit = nonempty(
58
$request->getValue('limit'),
59
self::DEFAULT_LIMIT);
60
61
$history_result = DiffusionQuery::callConduitWithDiffusionRequest(
62
$request->getUser(),
63
$drequest,
64
'diffusion.historyquery',
65
array(
66
'commit' => $drequest->getCommit(),
67
'path' => $drequest->getPath(),
68
'offset' => 0,
69
'limit' => $limit,
70
'needDirectChanges' => true,
71
'needChildChanges' => true,
72
));
73
$history = DiffusionPathChange::newFromConduit(
74
$history_result['pathChanges']);
75
76
$raw_commit_identifiers = mpull($history, 'getCommitIdentifier');
77
$result = array();
78
foreach ($raw_commit_identifiers as $id) {
79
$result[] = 'r'.$request->getValue('callsign').$id;
80
}
81
return $result;
82
}
83
84
}
85
86