diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -178,6 +178,7 @@ 'ArcanistTextLinterTestCase' => 'lint/linter/__tests__/ArcanistTextLinterTestCase.php', 'ArcanistTimeWorkflow' => 'workflow/ArcanistTimeWorkflow.php', 'ArcanistTodoWorkflow' => 'workflow/ArcanistTodoWorkflow.php', + 'ArcanistTryWorkflow' => 'workflow/ArcanistTryWorkflow.php', 'ArcanistUSEnglishTranslation' => 'internationalization/ArcanistUSEnglishTranslation.php', 'ArcanistUnitConsoleRenderer' => 'unit/renderer/ArcanistUnitConsoleRenderer.php', 'ArcanistUnitRenderer' => 'unit/renderer/ArcanistUnitRenderer.php', @@ -355,6 +356,7 @@ 'ArcanistTextLinterTestCase' => 'ArcanistLinterTestCase', 'ArcanistTimeWorkflow' => 'ArcanistPhrequentWorkflow', 'ArcanistTodoWorkflow' => 'ArcanistWorkflow', + 'ArcanistTryWorkflow' => 'ArcanistWorkflow', 'ArcanistUSEnglishTranslation' => 'PhutilTranslation', 'ArcanistUnitConsoleRenderer' => 'ArcanistUnitRenderer', 'ArcanistUnitTestableLintEngine' => 'ArcanistLintEngine', diff --git a/src/workflow/ArcanistTryWorkflow.php b/src/workflow/ArcanistTryWorkflow.php new file mode 100644 --- /dev/null +++ b/src/workflow/ArcanistTryWorkflow.php @@ -0,0 +1,110 @@ +getConduit(); + $api = $this->getRepositoryAPI(); + $staging = $this->getRepositoryStaging(); + + if ($staging == null || !idx($staging, 'supported', false)) { + throw new ArcanistUsageException(pht( + 'This project does not have a staging repository.')); + } + + $build_plan_id = $this->getConfigFromAnySource('try.buildplanid'); + + if ($build_plan_id === null) { + throw new ArcanistUsageException(pht( + 'No build plan ID configured for project; set '. + '\'try.buildplanid\' in .arcconfig first.')); + } + + $uri = idx($staging, 'uri'); + + echo pht("Pushing HEAD to staging repository...\n"); + + $api->execxLocal( + 'push -f %s HEAD:temporary-%s', + $uri, + Filesystem::readRandomCharacters(20)); + + list($commit_ref, $stderr) = $api->execxLocal('rev-parse HEAD'); + + echo pht( + "Scheduling build plan %d on %s...\n", + $build_plan_id, + trim($commit_ref)); + + $url = null; + while (true) { + try { + $url = $conduit->callMethodSynchronous( + 'harbormaster.startmanualbuild', + array( + 'commitIdentifier' => trim($commit_ref), + 'buildPlanID' => $build_plan_id, + )); + break; + } catch (ConduitClientException $ex) { + if (substr_count($ex->getMessage(), 'No such commit!') > 0) { + echo pht("Commit not yet parsed (waiting 5 seconds)...\n"); + sleep(5); + } + } + } + + echo pht("Build started at %s\n", $url); + + return 0; + } + + +} diff --git a/src/workflow/ArcanistWorkflow.php b/src/workflow/ArcanistWorkflow.php --- a/src/workflow/ArcanistWorkflow.php +++ b/src/workflow/ArcanistWorkflow.php @@ -1704,6 +1704,19 @@ /** + * Get the staging information of the Phabricator repository this + * working copy corresponds to. + * + * @return array|null Repository staging information, if present. + * + * @task phabrep + */ + final protected function getRepositoryStaging() { + return idx($this->getRepositoryInformation(), 'staging'); + } + + + /** * Get human-readable reasoning explaining how `arc` evaluated which * Phabricator repository corresponds to this working copy. Used by * `arc which` to explain the process to users.