Allow configuration of a "staging area" for each repository
Summary: Ref T8238. This allows configuration of a "staging area" for Git repositories, which is the URI to some Git repository (possibly the same repository). If a staging area is configured, `arc` will push a copy of anything it creates a diff for there (see next revision). This primarily makes handoff to build systems easier. This is a bit leaky and I intend for it to eventually be positioned as a less-preferred solution, but from the perspective of build systems it's the same as the real (virtual ref) solution that I want to build. Test Plan: Ran `arc diff` with various flags, saw appropriate changes copied into the staging area. See also discussion in T8238. Reviewers: btrahan Reviewed By: btrahan Subscribers: cburroughs, epriestley Maniphest Tasks: T8238 Differential Revision: https://secure.phabricator.com/D13019
This commit is contained in:
@@ -30,6 +30,7 @@ final class DiffusionRepositoryEditMainController
|
||||
|
||||
$has_branches = ($is_git || $is_hg);
|
||||
$has_local = $repository->usesLocalWorkingCopy();
|
||||
$supports_staging = $repository->supportsStaging();
|
||||
|
||||
$crumbs = $this->buildApplicationCrumbs($is_main = true);
|
||||
|
||||
@@ -92,6 +93,13 @@ final class DiffusionRepositoryEditMainController
|
||||
$this->buildStorageActions($repository));
|
||||
}
|
||||
|
||||
$staging_properties = null;
|
||||
if ($supports_staging) {
|
||||
$staging_properties = $this->buildStagingProperties(
|
||||
$repository,
|
||||
$this->buildStagingActions($repository));
|
||||
}
|
||||
|
||||
$actions_properties = $this->buildActionsProperties(
|
||||
$repository,
|
||||
$this->buildActionsActions($repository));
|
||||
@@ -157,6 +165,12 @@ final class DiffusionRepositoryEditMainController
|
||||
->addPropertyList($storage_properties);
|
||||
}
|
||||
|
||||
if ($staging_properties) {
|
||||
$boxes[] = id(new PHUIObjectBoxView())
|
||||
->setHeaderText(pht('Staging'))
|
||||
->addPropertyList($staging_properties);
|
||||
}
|
||||
|
||||
$boxes[] = id(new PHUIObjectBoxView())
|
||||
->setHeaderText(pht('Text Encoding'))
|
||||
->addPropertyList($encoding_properties);
|
||||
@@ -609,6 +623,45 @@ final class DiffusionRepositoryEditMainController
|
||||
return $view;
|
||||
}
|
||||
|
||||
|
||||
private function buildStagingActions(PhabricatorRepository $repository) {
|
||||
$viewer = $this->getViewer();
|
||||
|
||||
$view = id(new PhabricatorActionListView())
|
||||
->setObjectURI($this->getRequest()->getRequestURI())
|
||||
->setUser($viewer);
|
||||
|
||||
$edit = id(new PhabricatorActionView())
|
||||
->setIcon('fa-pencil')
|
||||
->setName(pht('Edit Staging'))
|
||||
->setHref(
|
||||
$this->getRepositoryControllerURI($repository, 'edit/staging/'));
|
||||
$view->addAction($edit);
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
private function buildStagingProperties(
|
||||
PhabricatorRepository $repository,
|
||||
PhabricatorActionListView $actions) {
|
||||
$viewer = $this->getViewer();
|
||||
|
||||
$view = id(new PHUIPropertyListView())
|
||||
->setUser($viewer)
|
||||
->setActionList($actions);
|
||||
|
||||
$staging_uri = $repository->getStagingURI();
|
||||
if (!$staging_uri) {
|
||||
$staging_uri = phutil_tag('em', array(), pht('No Staging Area'));
|
||||
}
|
||||
|
||||
$view->addProperty(
|
||||
pht('Staging Area'),
|
||||
$staging_uri);
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
private function buildHostingActions(PhabricatorRepository $repository) {
|
||||
$user = $this->getRequest()->getUser();
|
||||
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
final class DiffusionRepositoryEditStagingController
|
||||
extends DiffusionRepositoryEditController {
|
||||
|
||||
protected function processDiffusionRequest(AphrontRequest $request) {
|
||||
$user = $request->getUser();
|
||||
$drequest = $this->diffusionRequest;
|
||||
$repository = $drequest->getRepository();
|
||||
|
||||
$repository = id(new PhabricatorRepositoryQuery())
|
||||
->setViewer($user)
|
||||
->requireCapabilities(
|
||||
array(
|
||||
PhabricatorPolicyCapability::CAN_VIEW,
|
||||
PhabricatorPolicyCapability::CAN_EDIT,
|
||||
))
|
||||
->withIDs(array($repository->getID()))
|
||||
->executeOne();
|
||||
if (!$repository) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
if (!$repository->supportsStaging()) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
$edit_uri = $this->getRepositoryControllerURI($repository, 'edit/');
|
||||
|
||||
$v_area = $repository->getHumanReadableDetail('staging-uri');
|
||||
if ($request->isFormPost()) {
|
||||
$v_area = $request->getStr('area');
|
||||
|
||||
$xactions = array();
|
||||
$template = id(new PhabricatorRepositoryTransaction());
|
||||
|
||||
$type_encoding = PhabricatorRepositoryTransaction::TYPE_STAGING_URI;
|
||||
|
||||
$xactions[] = id(clone $template)
|
||||
->setTransactionType($type_encoding)
|
||||
->setNewValue($v_area);
|
||||
|
||||
id(new PhabricatorRepositoryEditor())
|
||||
->setContinueOnNoEffect(true)
|
||||
->setContentSourceFromRequest($request)
|
||||
->setActor($user)
|
||||
->applyTransactions($repository, $xactions);
|
||||
|
||||
return id(new AphrontRedirectResponse())->setURI($edit_uri);
|
||||
}
|
||||
|
||||
$crumbs = $this->buildApplicationCrumbs();
|
||||
$crumbs->addTextCrumb(pht('Edit Staging'));
|
||||
|
||||
$title = pht('Edit %s', $repository->getName());
|
||||
|
||||
$form = id(new AphrontFormView())
|
||||
->setUser($user)
|
||||
->appendRemarkupInstructions(
|
||||
pht(
|
||||
"To make it easier to run integration tests and builds on code ".
|
||||
"under review, you can configure a **Staging Area**. When `arc` ".
|
||||
"creates a diff, it will push a copy of the changes to the ".
|
||||
"configured staging area with a corresponding tag.".
|
||||
"\n\n".
|
||||
"IMPORTANT: This feature is new, experimental, and not supported. ".
|
||||
"Use it at your own risk."))
|
||||
->appendChild(
|
||||
id(new AphrontFormTextControl())
|
||||
->setLabel(pht('Staging Area URI'))
|
||||
->setName('area')
|
||||
->setValue($v_area))
|
||||
->appendChild(
|
||||
id(new AphrontFormSubmitControl())
|
||||
->setValue(pht('Save'))
|
||||
->addCancelButton($edit_uri));
|
||||
|
||||
$object_box = id(new PHUIObjectBoxView())
|
||||
->setHeaderText($title)
|
||||
->setForm($form);
|
||||
|
||||
return $this->buildApplicationPage(
|
||||
array(
|
||||
$crumbs,
|
||||
$object_box,
|
||||
),
|
||||
array(
|
||||
'title' => $title,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user