Summary: Ref T603. This swaps almost all queries against the repository table over to be policy aware. Test Plan: - Made an audit comment on a commit. - Ran `save_lint.php`. - Looked up a commit with `diffusion.getcommits`. - Looked up lint messages with `diffusion.getlintmessages`. - Clicked an external/submodule in Diffusion. - Viewed main lint and repository lint in Diffusion. - Completed and validated Owners paths in Owners. - Executed dry runs via Herald. - Queried for package owners with `owners.query`. - Viewed Owners package. - Edited Owners package. - Viewed Owners package list. - Executed `repository.query`. - Viewed "Repository" tool repository list. - Edited Arcanist project. - Hit "Delete" on repository (this just tells you to use the CLI). - Created a repository. - Edited a repository. - Ran `bin/repository list`. - Ran `bin/search index rGTESTff45d13dffcfb3ea85b03aac8cc36251cacdf01c` - Pushed and parsed a commit. - Skipped all the Drydock stuff, as it it's hard to test and isn't normally reachable. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T603 Differential Revision: https://secure.phabricator.com/D7132
56 lines
1.5 KiB
PHP
56 lines
1.5 KiB
PHP
<?php
|
|
|
|
final class PhabricatorRepositoryDeleteController
|
|
extends PhabricatorRepositoryController {
|
|
|
|
private $id;
|
|
|
|
public function willProcessRequest(array $data) {
|
|
$this->id = $data['id'];
|
|
}
|
|
|
|
public function processRequest() {
|
|
$viewer = $this->getRequest()->getUser();
|
|
|
|
$repository = id(new PhabricatorRepositoryQuery())
|
|
->setViewer($viewer)
|
|
->withIDs(array($this->id))
|
|
->executeOne();
|
|
if (!$repository) {
|
|
return new Aphront404Response();
|
|
}
|
|
|
|
$request = $this->getRequest();
|
|
|
|
if ($request->isDialogFormPost()) {
|
|
return id(new AphrontRedirectResponse())->setURI('/repository/');
|
|
}
|
|
|
|
$dialog = new AphrontDialogView();
|
|
$text_1 = pht('If you really want to delete the repository, you must run:');
|
|
$command = 'bin/repository delete '.$repository->getCallsign();
|
|
$text_2 = pht('Repositories touch many objects and as such deletes are '.
|
|
'prohibitively expensive to run from the web UI.');
|
|
$body = phutil_tag(
|
|
'div',
|
|
array(
|
|
'class' => 'phabricator-remarkup',
|
|
),
|
|
array(
|
|
phutil_tag('p', array(), $text_1),
|
|
phutil_tag('p', array(),
|
|
phutil_tag('tt', array(), $command)),
|
|
phutil_tag('p', array(), $text_2),
|
|
));
|
|
|
|
$dialog
|
|
->setUser($request->getUser())
|
|
->setTitle(pht('Really want to delete the repository?'))
|
|
->appendChild($body)
|
|
->setSubmitURI('/repository/delete/'.$this->id.'/')
|
|
->addSubmitButton(pht('Okay'));
|
|
|
|
return id(new AphrontDialogResponse())->setDialog($dialog);
|
|
}
|
|
}
|