Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/__phutil_library_map__.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
'ArcanistBraceFormattingXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistBraceFormattingXHPASTLinterRuleTestCase.php',
'ArcanistBranchWorkflow' => 'workflow/ArcanistBranchWorkflow.php',
'ArcanistBrowseWorkflow' => 'workflow/ArcanistBrowseWorkflow.php',
'ArcanistBuildableWorkflow' => 'workflow/ArcanistBuildableWorkflow.php',
'ArcanistBuildPlanRef' => 'ref/ArcanistBuildPlanRef.php',
'ArcanistBuildRef' => 'ref/ArcanistBuildRef.php',
'ArcanistBulkPatchWorkflow' => 'workflow/ArcanistBulkPatchWorkflow.php',
Expand Down Expand Up @@ -563,6 +564,7 @@
'ArcanistBraceFormattingXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
'ArcanistBranchWorkflow' => 'ArcanistFeatureWorkflow',
'ArcanistBrowseWorkflow' => 'ArcanistWorkflow',
'ArcanistBuildableWorkflow' => 'ArcanistWorkflow',
'ArcanistBuildPlanRef' => 'Phobject',
'ArcanistBuildRef' => 'Phobject',
'ArcanistBulkPatchWorkflow' => 'ArcanistDiffBasedWorkflow',
Expand Down
101 changes: 101 additions & 0 deletions src/workflow/ArcanistBuildableWorkflow.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?php

final class ArcanistBuildableWorkflow extends ArcanistWorkflow {

public function getWorkflowName() {
return 'buildable';
}

public function getCommandSynopses() {
return phutil_console_format(<<<EOTEXT
**buildable** --id __revisionID__
**buildable** --phid __revisionPHID__
EOTEXT
);
}

public function getCommandHelp() {
return phutil_console_format(<<<EOTEXT
Supports: http, https
Fetch Harbormaster buildable summary for a Differential revision.

- Specify either --id or --phid to identify the revision.
- Prints the raw JSON response to stdout.

Examples:

$ arc buildable --id=12345
$ arc buildable --phid=PHID-DREV-abc123
EOTEXT
);
}

public function getArguments() {
return array(
'id' => array(
'param' => 'id',
'help' => pht('Differential revision ID (e.g., 12345).'),
'conflicts' => array(
'phid' => pht('Specify either --id or --phid, not both.'),
),
),
'phid' => array(
'param' => 'phid',
'help' => pht('Differential revision PHID (e.g., PHID-DREV-...).'),
'conflicts' => array(
'id' => pht('Specify either --phid or --id, not both.'),
),
),
);
}

protected function shouldShellComplete() {
return false;
}

public function requiresConduit() {
return true;
}

public function requiresAuthentication() {
return true;
}

public function run() {
$revision_id = $this->getArgument('id');
$revision_phid = $this->getArgument('phid');

if (!$revision_id && !$revision_phid) {
throw new ArcanistUsageException(
pht('You must specify either --id or --phid to identify the revision.'));
}

$params = array();
if ($revision_id) {
// Normalize like other commands do; accept forms like "D1234".
$params['revisionID'] = (int)$this->normalizeRevisionID($revision_id);
}
if ($revision_phid) {
$params['revisionPHID'] = (string)$revision_phid;
}

try {
$result = $this->getConduit()->callMethodSynchronous(
'harbormaster.getbuildablesummary',
$params);
} catch (ConduitClientException $ex) {
// Match arc call-conduit output shape for errors.
echo json_encode(array(
'error' => $ex->getErrorCode(),
'errorMessage' => $ex->getMessage(),
'response' => null,
))."\n";
return 1;
}

echo json_encode($result)."\n";

return 0;
}
}