3 final class DiffusionRepositoryEditEnormousController
4 extends DiffusionRepositoryManageController
{
6 public function handleRequest(AphrontRequest
$request) {
7 $response = $this->loadDiffusionContextForEdit();
12 $viewer = $this->getViewer();
13 $drequest = $this->getDiffusionRequest();
14 $repository = $drequest->getRepository();
16 $panel_uri = id(new DiffusionRepositoryBasicsManagementPanel())
17 ->setRepository($repository)
20 if (!$repository->canAllowEnormousChanges()) {
21 return $this->newDialog()
22 ->setTitle(pht('Unprotectable Repository'))
25 'This repository can not be protected from enormous changes '.
26 'because this server does not control what users are allowed '.
28 ->addCancelButton($panel_uri);
31 if ($request->isFormPost()) {
32 $xaction = id(new PhabricatorRepositoryTransaction())
34 PhabricatorRepositoryEnormousTransaction
::TRANSACTIONTYPE
)
35 ->setNewValue(!$repository->shouldAllowEnormousChanges());
37 $editor = id(new PhabricatorRepositoryEditor())
38 ->setContinueOnNoEffect(true)
39 ->setContentSourceFromRequest($request)
41 ->applyTransactions($repository, array($xaction));
43 return id(new AphrontReloadResponse())->setURI($panel_uri);
46 if ($repository->shouldAllowEnormousChanges()) {
47 $title = pht('Prevent Enormous Changes');
50 'It will no longer be possible to push enormous changes to this '.
53 $submit = pht('Prevent Enormous Changes');
55 $title = pht('Allow Enormous Changes');
59 'If you allow enormous changes, users can push commits which are '.
60 'too large for Herald to process content rules for. This can allow '.
61 'users to evade content rules implemented in Herald.'),
63 'You can selectively configure Herald by adding rules to prevent a '.
64 'subset of enormous changes (for example, based on who is trying '.
65 'to push the change).'),
68 $submit = pht('Allow Enormous Changes');
72 'Enormous changes are commits which are too large to process with '.
73 'content rules because: the diff text for the change is larger than '.
74 '%s bytes; or the diff text takes more than %s seconds to extract.',
75 new PhutilNumber(HeraldCommitAdapter
::getEnormousByteLimit()),
76 new PhutilNumber(HeraldCommitAdapter
::getEnormousTimeLimit()));
78 $response = $this->newDialog();
80 foreach ((array)$body as $paragraph) {
81 $response->appendParagraph($paragraph);
86 ->appendParagraph($more_help)
87 ->addSubmitButton($submit)
88 ->addCancelButton($panel_uri);