forked from phacility/arcanist
-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathArcanistBuildableWorkflow.php
More file actions
85 lines (69 loc) · 2.16 KB
/
Copy pathArcanistBuildableWorkflow.php
File metadata and controls
85 lines (69 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
final class ArcanistBuildableWorkflow extends ArcanistWorkflow {
public function getWorkflowName() {
return 'buildable';
}
public function getCommandSynopses() {
return phutil_console_format(<<<EOTEXT
**buildable** [--id __id__ | --phid __phid__]
EOTEXT
);
}
public function getCommandHelp() {
return phutil_console_format(<<<EOTEXT
Supports: http, https
Fetch a Harbormaster buildable summary for a Differential revision.
Exactly one of these must be provided:
- **--id**: Differential revision ID (e.g. 123 or D123)
- **--phid**: Differential revision PHID (e.g. PHID-DREV-...)
Examples:
$ arc buildable --id=123
$ arc buildable --phid=PHID-DREV-abc123
EOTEXT
);
}
public function requiresConduit() {
return true;
}
public function requiresAuthentication() {
return true;
}
public function getArguments() {
return array(
'id' => array(
'param' => 'id',
'help' => pht('Differential revision ID (e.g. 123 or D123).'),
),
'phid' => array(
'param' => 'phid',
'help' => pht('Differential revision PHID (e.g. PHID-DREV-...).'),
'conflicts' => array(
'id' => pht('Specify either --id or --phid, but not both.'),
),
),
);
}
public function run() {
$revision_id = $this->getArgument('id');
$revision_phid = $this->getArgument('phid');
if (!$revision_id && !$revision_phid) {
throw new ArcanistUsageException(
pht('Specify either --id or --phid.'));
}
if ($revision_id) {
$revision_id = $this->normalizeRevisionID($revision_id);
if (!ctype_digit((string)$revision_id)) {
throw new ArcanistUsageException(
pht('Revision id must be a numeric value like 123 or D123.'));
}
$params = array('revisionID' => (int)$revision_id);
} else {
$params = array('revisionPHID' => (string)$revision_phid);
}
$result = $this->getConduit()->callMethodSynchronous(
'harbormaster.getbuildablesummary',
$params);
echo json_encode($result)."\n";
return 0;
}
}