Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/differential/conduit/DifferentialGetCommitPathsConduitAPIMethod.php
12256 views
1
<?php
2
3
final class DifferentialGetCommitPathsConduitAPIMethod
4
extends DifferentialConduitAPIMethod {
5
6
public function getAPIMethodName() {
7
return 'differential.getcommitpaths';
8
}
9
10
public function getMethodDescription() {
11
return pht(
12
'Query which paths should be included when committing a '.
13
'Differential revision.');
14
}
15
16
protected function defineParamTypes() {
17
return array(
18
'revision_id' => 'required int',
19
);
20
}
21
22
protected function defineReturnType() {
23
return 'nonempty list<string>';
24
}
25
26
protected function defineErrorTypes() {
27
return array(
28
'ERR_NOT_FOUND' => pht('No such revision exists.'),
29
);
30
}
31
32
protected function execute(ConduitAPIRequest $request) {
33
$id = $request->getValue('revision_id');
34
35
$revision = id(new DifferentialRevisionQuery())
36
->setViewer($request->getUser())
37
->withIDs(array($id))
38
->executeOne();
39
if (!$revision) {
40
throw new ConduitException('ERR_NOT_FOUND');
41
}
42
43
$paths = array();
44
$diff = id(new DifferentialDiff())->loadOneWhere(
45
'revisionID = %d ORDER BY id DESC limit 1',
46
$revision->getID());
47
48
$diff->attachChangesets($diff->loadChangesets());
49
50
foreach ($diff->getChangesets() as $changeset) {
51
$paths[] = $changeset->getFilename();
52
}
53
54
return $paths;
55
}
56
57
}
58
59