1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 00:42:41 +01:00

Remove "arcanist projects" from Releeph

Summary: Ref T7604. Remove arcanist projects from #releeph.

Test Plan: I don't really know how to use Releeph but I clicked around and nothing seemed too broken.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T7604

Differential Revision: https://secure.phabricator.com/D12898
This commit is contained in:
Joshua Spence 2015-05-26 07:06:12 +10:00
parent e8dbdedbd4
commit 205adbdda1
11 changed files with 48 additions and 230 deletions

View file

@ -0,0 +1,2 @@
ALTER TABLE {$NAMESPACE}_releeph.releeph_project
MODIFY arcanistProjectID int(10) unsigned NULL;

View file

@ -3151,7 +3151,6 @@ phutil_register_library_map(array(
'ReleephProductTransactionQuery' => 'applications/releeph/query/ReleephProductTransactionQuery.php',
'ReleephProductViewController' => 'applications/releeph/controller/product/ReleephProductViewController.php',
'ReleephProject' => 'applications/releeph/storage/ReleephProject.php',
'ReleephProjectInfoConduitAPIMethod' => 'applications/releeph/conduit/ReleephProjectInfoConduitAPIMethod.php',
'ReleephQueryBranchesConduitAPIMethod' => 'applications/releeph/conduit/ReleephQueryBranchesConduitAPIMethod.php',
'ReleephQueryProductsConduitAPIMethod' => 'applications/releeph/conduit/ReleephQueryProductsConduitAPIMethod.php',
'ReleephQueryRequestsConduitAPIMethod' => 'applications/releeph/conduit/ReleephQueryRequestsConduitAPIMethod.php',
@ -6734,7 +6733,6 @@ phutil_register_library_map(array(
'PhabricatorApplicationTransactionInterface',
'PhabricatorPolicyInterface',
),
'ReleephProjectInfoConduitAPIMethod' => 'ReleephConduitAPIMethod',
'ReleephQueryBranchesConduitAPIMethod' => 'ReleephConduitAPIMethod',
'ReleephQueryProductsConduitAPIMethod' => 'ReleephConduitAPIMethod',
'ReleephQueryRequestsConduitAPIMethod' => 'ReleephConduitAPIMethod',

View file

@ -1,100 +0,0 @@
<?php
final class ReleephProjectInfoConduitAPIMethod extends ReleephConduitAPIMethod {
public function getAPIMethodName() {
return 'releeph.projectinfo';
}
public function getMethodDescription() {
return pht(
'Fetch information about all Releeph projects '.
'for a given Arcanist project.');
}
protected function defineParamTypes() {
return array(
'arcProjectName' => 'optional string',
);
}
protected function defineReturnType() {
return 'dict<string, wild>';
}
protected function defineErrorTypes() {
return array(
'ERR_UNKNOWN_ARC' => pht(
"The given Arcanist project name doesn't exist in the ".
"installation of Phabricator you are accessing."),
);
}
protected function execute(ConduitAPIRequest $request) {
$arc_project_name = $request->getValue('arcProjectName');
if ($arc_project_name) {
$arc_project = id(new PhabricatorRepositoryArcanistProject())
->loadOneWhere('name = %s', $arc_project_name);
if (!$arc_project) {
throw id(new ConduitException('ERR_UNKNOWN_ARC'))
->setErrorDescription(
pht(
"Unknown Arcanist project '%s': ".
"are you using the correct Conduit URI?",
$arc_project_name));
}
$releeph_projects = id(new ReleephProject())
->loadAllWhere('arcanistProjectID = %d', $arc_project->getID());
} else {
$releeph_projects = id(new ReleephProject())->loadAll();
}
$releeph_projects = mfilter($releeph_projects, 'getIsActive');
$result = array();
foreach ($releeph_projects as $releeph_project) {
$selector = $releeph_project->getReleephFieldSelector();
$fields = $selector->getFieldSpecifications();
$fields_info = array();
foreach ($fields as $field) {
$field->setReleephProject($releeph_project);
if ($field->isEditable()) {
$key = $field->getKeyForConduit();
$fields_info[$key] = array(
'class' => get_class($field),
'name' => $field->getName(),
'key' => $key,
'arcHelp' => $field->renderHelpForArcanist(),
);
}
}
$releeph_branches = mfilter(
id(new ReleephBranch())
->loadAllWhere('releephProjectID = %d', $releeph_project->getID()),
'getIsActive');
$releeph_branches_struct = array();
foreach ($releeph_branches as $branch) {
$releeph_branches_struct[] = array(
'branchName' => $branch->getName(),
'projectName' => $releeph_project->getName(),
'projectPHID' => $releeph_project->getPHID(),
'branchPHID' => $branch->getPHID(),
);
}
$result[] = array(
'projectName' => $releeph_project->getName(),
'projectPHID' => $releeph_project->getPHID(),
'branches' => $releeph_branches_struct,
'fields' => $fields_info,
);
}
return $result;
}
}

View file

@ -13,10 +13,10 @@ final class ReleephBranchNamePreviewController
$template = ReleephBranchTemplate::getDefaultTemplate();
}
$arc_project_id = $request->getInt('arcProjectID');
$repository_phid = $request->getInt('repositoryPHID');
$fake_commit_handle =
ReleephBranchTemplate::getFakeCommitHandleFor(
$arc_project_id,
$repository_phid,
$request->getUser());
list($name, $errors) = id(new ReleephBranchTemplate())

View file

@ -6,9 +6,7 @@ final class ReleephProductCreateController extends ReleephProductController {
$request = $this->getRequest();
$name = trim($request->getStr('name'));
$trunk_branch = trim($request->getStr('trunkBranch'));
$arc_pr_id = $request->getInt('arcPrID');
$arc_projects = $this->loadArcProjects();
$repository_phid = $request->getStr('repositoryPHID');
$e_name = true;
$e_trunk_branch = true;
@ -27,14 +25,10 @@ final class ReleephProductCreateController extends ReleephProductController {
'You must specify which branch you will be picking from.');
}
$arc_project = $arc_projects[$arc_pr_id];
$pr_repository = null;
if ($arc_project->getRepositoryID()) {
$pr_repository = id(new PhabricatorRepositoryQuery())
->setViewer($request->getUser())
->withIDs(array($arc_project->getRepositoryID()))
->executeOne();
}
$pr_repository = id(new PhabricatorRepositoryQuery())
->setViewer($request->getUser())
->withPHIDs(array($repository_phid))
->executeOne();
if (!$errors) {
@ -42,7 +36,6 @@ final class ReleephProductCreateController extends ReleephProductController {
->setName($name)
->setTrunkBranch($trunk_branch)
->setRepositoryPHID($pr_repository->getPHID())
->setArcanistProjectID($arc_project->getID())
->setCreatedByUserPHID($request->getUser()->getPHID())
->setIsActive(1);
@ -58,7 +51,7 @@ final class ReleephProductCreateController extends ReleephProductController {
}
}
$arc_project_options = $this->getArcProjectSelectOptions($arc_projects);
$repo_options = $this->getRepositorySelectOptions();
$product_name_input = id(new AphrontFormTextControl())
->setLabel(pht('Name'))
@ -68,32 +61,23 @@ final class ReleephProductCreateController extends ReleephProductController {
->setError($e_name)
->setCaption(pht('A name like "Thrift" but not "Thrift releases".'));
$arc_project_input = id(new AphrontFormSelectControl())
->setLabel(pht('Arc Project'))
->setName('arcPrID')
->setValue($arc_pr_id)
->setCaption(pht(
"If your Arc project isn't listed, associate it with a repository %s.",
phutil_tag(
'a',
array(
'href' => '/repository/',
'target' => '_blank',
),
'here')))
->setOptions($arc_project_options);
$repository_input = id(new AphrontFormSelectControl())
->setLabel(pht('Repository'))
->setName('repositoryPHID')
->setValue($repository_phid)
->setOptions($repo_options);
$branch_name_preview = id(new ReleephBranchPreviewView())
->setLabel(pht('Example Branch'))
->addControl('projectName', $product_name_input)
->addControl('arcProjectID', $arc_project_input)
->addControl('repositoryPHID', $repository_input)
->addStatic('template', '')
->addStatic('isSymbolic', false);
$form = id(new AphrontFormView())
->setUser($request->getUser())
->appendChild($product_name_input)
->appendChild($arc_project_input)
->appendChild($repository_input)
->appendChild(
id(new AphrontFormTextControl())
->setLabel(pht('Trunk'))
@ -126,43 +110,23 @@ final class ReleephProductCreateController extends ReleephProductController {
));
}
private function loadArcProjects() {
$viewer = $this->getRequest()->getUser();
$projects = id(new PhabricatorRepositoryArcanistProjectQuery())
->setViewer($viewer)
->needRepositories(true)
private function getRepositorySelectOptions() {
$repos = id(new PhabricatorRepositoryQuery())
->setViewer($this->getRequest()->getUser())
->execute();
$projects = mfilter($projects, 'getRepository');
$projects = msort($projects, 'getName');
return $projects;
}
private function getArcProjectSelectOptions(array $arc_projects) {
assert_instances_of($arc_projects, 'PhabricatorRepositoryArcanistProject');
$repos = mpull($arc_projects, 'getRepository');
$repos = msort($repos, 'getName');
$repos = mpull($repos, null, 'getID');
$groups = array();
foreach ($arc_projects as $arc_project) {
$id = $arc_project->getID();
$repo_id = $arc_project->getRepository()->getID();
$groups[$repo_id][$id] = $arc_project->getName();
}
$choices = array();
foreach ($groups as $repo_id => $group) {
$repo_name = $repos[$repo_id]->getName();
$callsign = $repos[$repo_id]->getCallsign();
$name = "r{$callsign} ({$repo_name})";
$choices[$name] = $group;
foreach ($repos as $repo_id => $repo) {
$repo_name = $repo->getName();
$callsign = $repo->getCallsign();
$choices[$repo->getPHID()] = "r{$callsign} ({$repo_name})";
}
ksort($choices);
return $choices;
}

View file

@ -15,7 +15,6 @@ final class ReleephProductEditController extends ReleephProductController {
$product = id(new ReleephProductQuery())
->setViewer($viewer)
->withIDs(array($this->productID))
->needArcanistProjects(true)
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
@ -48,7 +47,7 @@ final class ReleephProductEditController extends ReleephProductController {
$test_paths = $product->getDetail('testPaths', array());
}
$arc_project_id = $product->getArcanistProjectID();
$repository_phid = $product->getRepositoryPHID();
if ($request->isFormPost()) {
$pusher_phids = $request->getArr('pushers');
@ -92,8 +91,9 @@ final class ReleephProductEditController extends ReleephProductController {
->setDetail('branchTemplate', $branch_template)
->setDetail('testPaths', $test_paths);
$fake_commit_handle =
ReleephBranchTemplate::getFakeCommitHandleFor($arc_project_id, $viewer);
$fake_commit_handle = ReleephBranchTemplate::getFakeCommitHandleFor(
$repository_phid,
$viewer);
if ($branch_template) {
list($branch_name, $template_errors) = id(new ReleephBranchTemplate())
@ -136,9 +136,9 @@ final class ReleephProductEditController extends ReleephProductController {
$product->getRepository()->getName()))
->appendChild(
id(new AphrontFormStaticControl())
->setLabel(pht('Arc Project'))
->setLabel(pht('Repository'))
->setValue(
$product->getArcanistProject()->getName()))
$product->getRepository()->getName()))
->appendChild(
id(new AphrontFormStaticControl())
->setLabel(pht('Releeph Project PHID'))
@ -179,7 +179,7 @@ final class ReleephProductEditController extends ReleephProductController {
$branch_template_preview = id(new ReleephBranchPreviewView())
->setLabel(pht('Preview'))
->addControl('template', $branch_template_input)
->addStatic('arcProjectID', $arc_project_id)
->addStatic('repositoryPHID', $repository_phid)
->addStatic('isSymbolic', false)
->addStatic('projectName', $product->getName());

View file

@ -25,19 +25,18 @@ final class ReleephRequestDifferentialCreateController
}
$this->revision = $diff_rev;
$arc_project = id(new PhabricatorRepositoryArcanistProject())
->loadOneWhere('phid = %s', $this->revision->getArcanistProjectPHID());
$repository = $this->revision->getRepository();
$projects = id(new ReleephProject())->loadAllWhere(
'arcanistProjectID = %d AND isActive = 1',
$arc_project->getID());
'repositoryPHID = %s AND isActive = 1',
$repository->getPHID());
if (!$projects) {
throw new Exception(
pht(
"%s belongs to the '%s' Arcanist project, ".
"%s belongs to the '%s' repository, ".
"which is not part of any Releeph project!",
'D'.$this->revision->getID(),
$arc_project->getName()));
$repository->getMonogram()));
}
$branches = id(new ReleephBranch())->loadAllWhere(

View file

@ -8,8 +8,6 @@ final class ReleephProductQuery
private $phids;
private $repositoryPHIDs;
private $needArcanistProjects;
const ORDER_ID = 'order-id';
const ORDER_NAME = 'order-name';
@ -47,11 +45,6 @@ final class ReleephProductQuery
return $this;
}
public function needArcanistProjects($need) {
$this->needArcanistProjects = $need;
return $this;
}
protected function loadPage() {
$table = new ReleephProject();
$conn_r = $table->establishConnection('r');
@ -90,27 +83,6 @@ final class ReleephProductQuery
return $projects;
}
protected function didFilterPage(array $products) {
if ($this->needArcanistProjects) {
$project_ids = array_filter(mpull($products, 'getArcanistProjectID'));
if ($project_ids) {
$projects = id(new PhabricatorRepositoryArcanistProject())
->loadAllWhere('id IN (%Ld)', $project_ids);
$projects = mpull($projects, null, 'getID');
} else {
$projects = array();
}
foreach ($products as $product) {
$project_id = $product->getArcanistProjectID();
$project = idx($projects, $project_id);
$product->attachArcanistProject($project);
}
}
return $products;
}
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
$where = array();

View file

@ -21,8 +21,7 @@ final class ReleephProductSearchEngine
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
$query = id(new ReleephProductQuery())
->setOrder(ReleephProductQuery::ORDER_NAME)
->needArcanistProjects(true);
->setOrder(ReleephProductQuery::ORDER_NAME);
$active = $saved->getParameter('active');
$value = idx($this->getActiveValues(), $active);
@ -119,11 +118,6 @@ final class ReleephProductSearchEngine
),
'r'.$repo->getCallsign()));
$arc = $product->getArcanistProject();
if ($arc) {
$item->addAttribute($arc->getName());
}
$list->addItem($item);
}

View file

@ -24,7 +24,7 @@ final class ReleephBranchPreviewView extends AphrontFormControl {
protected function renderInput() {
static $required_params = array(
'arcProjectID',
'repositoryPHID',
'projectName',
'isSymbolic',
'template',
@ -43,9 +43,9 @@ final class ReleephBranchPreviewView extends AphrontFormControl {
$output_id = celerity_generate_unique_node_id();
Javelin::initBehavior('releeph-preview-branch', array(
'uri' => '/releeph/branch/preview/',
'outputID' => $output_id,
'params' => array(
'uri' => '/releeph/branch/preview/',
'outputID' => $output_id,
'params' => array(
'static' => $this->statics,
'dynamic' => $this->dynamics,
),

View file

@ -20,25 +20,14 @@ final class ReleephBranchTemplate {
}
public static function getFakeCommitHandleFor(
$arc_project_id,
$repository_phid,
PhabricatorUser $viewer) {
$arc_project = id(new PhabricatorRepositoryArcanistProject())
->load($arc_project_id);
if (!$arc_project) {
throw new Exception(
pht(
"No Arc project found with id '%s'!",
$arc_project_id));
}
$repository = id(new PhabricatorRepositoryQuery())
->setViewer($viewer)
->withPHIDs(array($repository_phid))
->executeOne();
$repository = null;
if ($arc_project->getRepositoryID()) {
$repository = id(new PhabricatorRepositoryQuery())
->setViewer($viewer)
->withIDs(array($arc_project->getRepositoryID()))
->executeOne();
}
$fake_handle = 'SOFAKE';
if ($repository) {
$fake_handle = id(new PhabricatorObjectHandle())