Differential D7825 Diff 17711 src/applications/harbormaster/controller/HarbormasterPlanRunController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/harbormaster/controller/HarbormasterPlanRunController.php
| Show All 35 Lines | if ($request->isFormPost()) { | ||||
| $v_name = $request->getStr('buildablePHID'); | $v_name = $request->getStr('buildablePHID'); | ||||
| if ($v_name) { | if ($v_name) { | ||||
| $object = id(new PhabricatorObjectQuery()) | $object = id(new PhabricatorObjectQuery()) | ||||
| ->setViewer($viewer) | ->setViewer($viewer) | ||||
| ->withNames(array($v_name)) | ->withNames(array($v_name)) | ||||
| ->executeOne(); | ->executeOne(); | ||||
| if ($object instanceof DifferentialRevision) { | if ($object instanceof HarbormasterBuildableInterface) { | ||||
| $revision = $object; | |||||
| $object = $object->loadActiveDiff(); | |||||
| $buildable | $buildable | ||||
| ->setBuildablePHID($object->getPHID()) | ->setBuildablePHID($object->getHarbormasterBuildablePHID()) | ||||
| ->setContainerPHID($revision->getPHID()); | ->setContainerPHID($object->getHarbormasterContainerPHID()); | ||||
| } else if ($object instanceof PhabricatorRepositoryCommit) { | |||||
| $buildable | |||||
| ->setBuildablePHID($object->getPHID()) | |||||
| ->setContainerPHID($object->getRepository()->getPHID()); | |||||
| } else { | } else { | ||||
| $e_name = pht('Invalid'); | $e_name = pht('Invalid'); | ||||
| $errors[] = pht('Enter the name of a revision or commit.'); | $errors[] = pht('Enter the name of a revision or commit.'); | ||||
| } | } | ||||
| } else { | } else { | ||||
| $e_name = pht('Required'); | $e_name = pht('Required'); | ||||
| $errors[] = pht('You must choose a revision or commit to build.'); | $errors[] = pht('You must choose a revision or commit to build.'); | ||||
| } | } | ||||
| if (!$errors) { | if (!$errors) { | ||||
| $buildable->save(); | $buildable->save(); | ||||
| $buildable->applyPlan($plan); | |||||
| $buildable_uri = '/B'.$buildable->getID(); | $buildable_uri = '/B'.$buildable->getID(); | ||||
| return id(new AphrontRedirectResponse())->setURI($buildable_uri); | return id(new AphrontRedirectResponse())->setURI($buildable_uri); | ||||
| } | } | ||||
| } | } | ||||
| if ($errors) { | if ($errors) { | ||||
| $errors = id(new AphrontErrorView())->setErrors($errors); | $errors = id(new AphrontErrorView())->setErrors($errors); | ||||
| } | } | ||||
| $title = pht('Run Build Plan Manually'); | $title = pht('Run Build Plan Manually'); | ||||
| $cancel_uri = $this->getApplicationURI("plan/{$plan_id}/"); | $cancel_uri = $this->getApplicationURI("plan/{$plan_id}/"); | ||||
| $save_button = pht('Run Plan Manually'); | $save_button = pht('Run Plan Manually'); | ||||
| $form = id(new PHUIFormLayoutView()) | $form = id(new PHUIFormLayoutView()) | ||||
| ->setUser($viewer) | ->setUser($viewer) | ||||
| ->appendRemarkupInstructions( | ->appendRemarkupInstructions( | ||||
| pht( | pht( | ||||
| "Enter the name of a commit or revision to run this plan on.\n\n". | "Enter the name of a commit or revision to run this plan on (for ". | ||||
| "For example: `rX123456` or `D123`")) | "example, `rX123456` or `D123`).\n\n". | ||||
| "For more detailed output, you can also run manual builds from ". | |||||
| "the command line:\n\n". | |||||
| " phabricator/ $ ./bin/harbormaster build <object> --plan %s", | |||||
| $plan->getID())) | |||||
| ->appendChild( | ->appendChild( | ||||
| id(new AphrontFormTextControl()) | id(new AphrontFormTextControl()) | ||||
| ->setLabel('Buildable Name') | ->setLabel('Buildable Name') | ||||
| ->setName('buildablePHID') | ->setName('buildablePHID') | ||||
| ->setError($e_name) | ->setError($e_name) | ||||
| ->setValue($v_name)); | ->setValue($v_name)); | ||||
| $dialog = id(new AphrontDialogView()) | $dialog = id(new AphrontDialogView()) | ||||
| ->setWidth(AphrontDialogView::WIDTH_FORM) | ->setWidth(AphrontDialogView::WIDTH_FULL) | ||||
| ->setUser($viewer) | ->setUser($viewer) | ||||
| ->setTitle($title) | ->setTitle($title) | ||||
| ->appendChild($form) | ->appendChild($form) | ||||
| ->addCancelButton($cancel_uri) | ->addCancelButton($cancel_uri) | ||||
| ->addSubmitButton($save_button); | ->addSubmitButton($save_button); | ||||
| return id(new AphrontDialogResponse())->setDialog($dialog); | return id(new AphrontDialogResponse())->setDialog($dialog); | ||||
| } | } | ||||
| } | } | ||||