2015-10-27 19:04:02 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class DiffusionRepositoryTestAutomationController
|
2016-05-09 23:24:21 +02:00
|
|
|
extends DiffusionRepositoryManageController {
|
2015-10-27 19:04:02 +01:00
|
|
|
|
2016-01-05 17:13:05 +01:00
|
|
|
public function handleRequest(AphrontRequest $request) {
|
2016-01-05 17:49:10 +01:00
|
|
|
$response = $this->loadDiffusionContextForEdit();
|
2016-01-05 17:13:05 +01:00
|
|
|
if ($response) {
|
|
|
|
return $response;
|
|
|
|
}
|
|
|
|
|
2015-10-27 19:04:02 +01:00
|
|
|
$viewer = $this->getViewer();
|
2016-01-05 17:13:05 +01:00
|
|
|
$drequest = $this->getDiffusionRequest();
|
2015-10-27 19:04:02 +01:00
|
|
|
$repository = $drequest->getRepository();
|
|
|
|
|
2016-05-09 16:01:37 +02:00
|
|
|
$panel_uri = id(new DiffusionRepositoryAutomationManagementPanel())
|
|
|
|
->setRepository($repository)
|
|
|
|
->getPanelURI();
|
2015-10-27 19:04:02 +01:00
|
|
|
|
|
|
|
if (!$repository->canPerformAutomation()) {
|
|
|
|
return $this->newDialog()
|
|
|
|
->setTitle(pht('Automation Not Configured'))
|
|
|
|
->appendParagraph(
|
|
|
|
pht(
|
|
|
|
'You can not run a configuration test for this repository '.
|
|
|
|
'because you have not configured repository automation yet. '.
|
|
|
|
'Configure it first, then test the configuration.'))
|
2016-05-09 16:01:37 +02:00
|
|
|
->addCancelButton($panel_uri);
|
2015-10-27 19:04:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($request->isFormPost()) {
|
|
|
|
$op = new DrydockTestRepositoryOperation();
|
|
|
|
|
|
|
|
$operation = DrydockRepositoryOperation::initializeNewOperation($op)
|
|
|
|
->setAuthorPHID($viewer->getPHID())
|
|
|
|
->setObjectPHID($repository->getPHID())
|
|
|
|
->setRepositoryPHID($repository->getPHID())
|
|
|
|
->setRepositoryTarget('none:')
|
|
|
|
->save();
|
|
|
|
|
|
|
|
$operation->scheduleUpdate();
|
|
|
|
|
|
|
|
$operation_id = $operation->getID();
|
|
|
|
$operation_uri = "/drydock/operation/{$operation_id}/";
|
|
|
|
|
|
|
|
return id(new AphrontRedirectResponse())
|
|
|
|
->setURI($operation_uri);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->newDialog()
|
|
|
|
->setTitle(pht('Test Automation Configuration'))
|
|
|
|
->appendParagraph(
|
|
|
|
pht(
|
|
|
|
'This configuration test will build a working copy of the '.
|
|
|
|
'repository and perform some basic validation. If it works, '.
|
|
|
|
'your configuration is substantially correct.'))
|
|
|
|
->appendParagraph(
|
|
|
|
pht(
|
|
|
|
'The test will not perform any writes against the repository, so '.
|
|
|
|
'write operations may still fail even if the test passes. This '.
|
|
|
|
'test covers building and reading working copies, but not writing '.
|
|
|
|
'to them.'))
|
|
|
|
->appendParagraph(
|
|
|
|
pht(
|
|
|
|
'If you run into write failures despite passing this test, '.
|
|
|
|
'it suggests that your setup is nearly correct but authentication '.
|
|
|
|
'is probably not fully configured.'))
|
2016-05-09 16:01:37 +02:00
|
|
|
->addCancelButton($panel_uri)
|
2015-10-27 19:04:02 +01:00
|
|
|
->addSubmitButton(pht('Start Test'));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|