From c159c9d4847a601f07b3a41f1661a450b0e08898 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 21 Sep 2025 16:09:45 +0000 Subject: [PATCH] Add ArcanistBuildableWorkflow to fetch buildable summaries Co-authored-by: wua --- src/__phutil_library_map__.php | 2 + src/workflow/ArcanistBuildableWorkflow.php | 101 +++++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 src/workflow/ArcanistBuildableWorkflow.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index f31cd3297..b09e0327e 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -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', @@ -563,6 +564,7 @@ 'ArcanistBraceFormattingXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase', 'ArcanistBranchWorkflow' => 'ArcanistFeatureWorkflow', 'ArcanistBrowseWorkflow' => 'ArcanistWorkflow', + 'ArcanistBuildableWorkflow' => 'ArcanistWorkflow', 'ArcanistBuildPlanRef' => 'Phobject', 'ArcanistBuildRef' => 'Phobject', 'ArcanistBulkPatchWorkflow' => 'ArcanistDiffBasedWorkflow', diff --git a/src/workflow/ArcanistBuildableWorkflow.php b/src/workflow/ArcanistBuildableWorkflow.php new file mode 100644 index 000000000..6fe0e8a91 --- /dev/null +++ b/src/workflow/ArcanistBuildableWorkflow.php @@ -0,0 +1,101 @@ + 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; + } +} +