1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 16:52: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', 'ReleephProductTransactionQuery' => 'applications/releeph/query/ReleephProductTransactionQuery.php',
'ReleephProductViewController' => 'applications/releeph/controller/product/ReleephProductViewController.php', 'ReleephProductViewController' => 'applications/releeph/controller/product/ReleephProductViewController.php',
'ReleephProject' => 'applications/releeph/storage/ReleephProject.php', 'ReleephProject' => 'applications/releeph/storage/ReleephProject.php',
'ReleephProjectInfoConduitAPIMethod' => 'applications/releeph/conduit/ReleephProjectInfoConduitAPIMethod.php',
'ReleephQueryBranchesConduitAPIMethod' => 'applications/releeph/conduit/ReleephQueryBranchesConduitAPIMethod.php', 'ReleephQueryBranchesConduitAPIMethod' => 'applications/releeph/conduit/ReleephQueryBranchesConduitAPIMethod.php',
'ReleephQueryProductsConduitAPIMethod' => 'applications/releeph/conduit/ReleephQueryProductsConduitAPIMethod.php', 'ReleephQueryProductsConduitAPIMethod' => 'applications/releeph/conduit/ReleephQueryProductsConduitAPIMethod.php',
'ReleephQueryRequestsConduitAPIMethod' => 'applications/releeph/conduit/ReleephQueryRequestsConduitAPIMethod.php', 'ReleephQueryRequestsConduitAPIMethod' => 'applications/releeph/conduit/ReleephQueryRequestsConduitAPIMethod.php',
@ -6734,7 +6733,6 @@ phutil_register_library_map(array(
'PhabricatorApplicationTransactionInterface', 'PhabricatorApplicationTransactionInterface',
'PhabricatorPolicyInterface', 'PhabricatorPolicyInterface',
), ),
'ReleephProjectInfoConduitAPIMethod' => 'ReleephConduitAPIMethod',
'ReleephQueryBranchesConduitAPIMethod' => 'ReleephConduitAPIMethod', 'ReleephQueryBranchesConduitAPIMethod' => 'ReleephConduitAPIMethod',
'ReleephQueryProductsConduitAPIMethod' => 'ReleephConduitAPIMethod', 'ReleephQueryProductsConduitAPIMethod' => 'ReleephConduitAPIMethod',
'ReleephQueryRequestsConduitAPIMethod' => '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(); $template = ReleephBranchTemplate::getDefaultTemplate();
} }
$arc_project_id = $request->getInt('arcProjectID'); $repository_phid = $request->getInt('repositoryPHID');
$fake_commit_handle = $fake_commit_handle =
ReleephBranchTemplate::getFakeCommitHandleFor( ReleephBranchTemplate::getFakeCommitHandleFor(
$arc_project_id, $repository_phid,
$request->getUser()); $request->getUser());
list($name, $errors) = id(new ReleephBranchTemplate()) list($name, $errors) = id(new ReleephBranchTemplate())

View file

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

View file

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

View file

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

View file

@ -8,8 +8,6 @@ final class ReleephProductQuery
private $phids; private $phids;
private $repositoryPHIDs; private $repositoryPHIDs;
private $needArcanistProjects;
const ORDER_ID = 'order-id'; const ORDER_ID = 'order-id';
const ORDER_NAME = 'order-name'; const ORDER_NAME = 'order-name';
@ -47,11 +45,6 @@ final class ReleephProductQuery
return $this; return $this;
} }
public function needArcanistProjects($need) {
$this->needArcanistProjects = $need;
return $this;
}
protected function loadPage() { protected function loadPage() {
$table = new ReleephProject(); $table = new ReleephProject();
$conn_r = $table->establishConnection('r'); $conn_r = $table->establishConnection('r');
@ -90,27 +83,6 @@ final class ReleephProductQuery
return $projects; 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) { protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
$where = array(); $where = array();

View file

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

View file

@ -24,7 +24,7 @@ final class ReleephBranchPreviewView extends AphrontFormControl {
protected function renderInput() { protected function renderInput() {
static $required_params = array( static $required_params = array(
'arcProjectID', 'repositoryPHID',
'projectName', 'projectName',
'isSymbolic', 'isSymbolic',
'template', 'template',

View file

@ -20,25 +20,14 @@ final class ReleephBranchTemplate {
} }
public static function getFakeCommitHandleFor( public static function getFakeCommitHandleFor(
$arc_project_id, $repository_phid,
PhabricatorUser $viewer) { 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 = null;
if ($arc_project->getRepositoryID()) {
$repository = id(new PhabricatorRepositoryQuery()) $repository = id(new PhabricatorRepositoryQuery())
->setViewer($viewer) ->setViewer($viewer)
->withIDs(array($arc_project->getRepositoryID())) ->withPHIDs(array($repository_phid))
->executeOne(); ->executeOne();
}
$fake_handle = 'SOFAKE'; $fake_handle = 'SOFAKE';
if ($repository) { if ($repository) {
$fake_handle = id(new PhabricatorObjectHandle()) $fake_handle = id(new PhabricatorObjectHandle())