@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+48 -230
+2
resources/sql/patches/20150521.releephrepository.sql
··· 1 + ALTER TABLE {$NAMESPACE}_releeph.releeph_project 2 + MODIFY arcanistProjectID int(10) unsigned NULL;
-2
src/__phutil_library_map__.php
··· 3151 3151 'ReleephProductTransactionQuery' => 'applications/releeph/query/ReleephProductTransactionQuery.php', 3152 3152 'ReleephProductViewController' => 'applications/releeph/controller/product/ReleephProductViewController.php', 3153 3153 'ReleephProject' => 'applications/releeph/storage/ReleephProject.php', 3154 - 'ReleephProjectInfoConduitAPIMethod' => 'applications/releeph/conduit/ReleephProjectInfoConduitAPIMethod.php', 3155 3154 'ReleephQueryBranchesConduitAPIMethod' => 'applications/releeph/conduit/ReleephQueryBranchesConduitAPIMethod.php', 3156 3155 'ReleephQueryProductsConduitAPIMethod' => 'applications/releeph/conduit/ReleephQueryProductsConduitAPIMethod.php', 3157 3156 'ReleephQueryRequestsConduitAPIMethod' => 'applications/releeph/conduit/ReleephQueryRequestsConduitAPIMethod.php', ··· 6734 6733 'PhabricatorApplicationTransactionInterface', 6735 6734 'PhabricatorPolicyInterface', 6736 6735 ), 6737 - 'ReleephProjectInfoConduitAPIMethod' => 'ReleephConduitAPIMethod', 6738 6736 'ReleephQueryBranchesConduitAPIMethod' => 'ReleephConduitAPIMethod', 6739 6737 'ReleephQueryProductsConduitAPIMethod' => 'ReleephConduitAPIMethod', 6740 6738 'ReleephQueryRequestsConduitAPIMethod' => 'ReleephConduitAPIMethod',
-100
src/applications/releeph/conduit/ReleephProjectInfoConduitAPIMethod.php
··· 1 - <?php 2 - 3 - final class ReleephProjectInfoConduitAPIMethod extends ReleephConduitAPIMethod { 4 - 5 - public function getAPIMethodName() { 6 - return 'releeph.projectinfo'; 7 - } 8 - 9 - public function getMethodDescription() { 10 - return pht( 11 - 'Fetch information about all Releeph projects '. 12 - 'for a given Arcanist project.'); 13 - } 14 - 15 - protected function defineParamTypes() { 16 - return array( 17 - 'arcProjectName' => 'optional string', 18 - ); 19 - } 20 - 21 - protected function defineReturnType() { 22 - return 'dict<string, wild>'; 23 - } 24 - 25 - protected function defineErrorTypes() { 26 - return array( 27 - 'ERR_UNKNOWN_ARC' => pht( 28 - "The given Arcanist project name doesn't exist in the ". 29 - "installation of Phabricator you are accessing."), 30 - ); 31 - } 32 - 33 - protected function execute(ConduitAPIRequest $request) { 34 - $arc_project_name = $request->getValue('arcProjectName'); 35 - if ($arc_project_name) { 36 - $arc_project = id(new PhabricatorRepositoryArcanistProject()) 37 - ->loadOneWhere('name = %s', $arc_project_name); 38 - if (!$arc_project) { 39 - throw id(new ConduitException('ERR_UNKNOWN_ARC')) 40 - ->setErrorDescription( 41 - pht( 42 - "Unknown Arcanist project '%s': ". 43 - "are you using the correct Conduit URI?", 44 - $arc_project_name)); 45 - } 46 - 47 - $releeph_projects = id(new ReleephProject()) 48 - ->loadAllWhere('arcanistProjectID = %d', $arc_project->getID()); 49 - } else { 50 - $releeph_projects = id(new ReleephProject())->loadAll(); 51 - } 52 - 53 - $releeph_projects = mfilter($releeph_projects, 'getIsActive'); 54 - 55 - $result = array(); 56 - foreach ($releeph_projects as $releeph_project) { 57 - $selector = $releeph_project->getReleephFieldSelector(); 58 - $fields = $selector->getFieldSpecifications(); 59 - 60 - $fields_info = array(); 61 - foreach ($fields as $field) { 62 - $field->setReleephProject($releeph_project); 63 - if ($field->isEditable()) { 64 - $key = $field->getKeyForConduit(); 65 - $fields_info[$key] = array( 66 - 'class' => get_class($field), 67 - 'name' => $field->getName(), 68 - 'key' => $key, 69 - 'arcHelp' => $field->renderHelpForArcanist(), 70 - ); 71 - } 72 - } 73 - 74 - $releeph_branches = mfilter( 75 - id(new ReleephBranch()) 76 - ->loadAllWhere('releephProjectID = %d', $releeph_project->getID()), 77 - 'getIsActive'); 78 - 79 - $releeph_branches_struct = array(); 80 - foreach ($releeph_branches as $branch) { 81 - $releeph_branches_struct[] = array( 82 - 'branchName' => $branch->getName(), 83 - 'projectName' => $releeph_project->getName(), 84 - 'projectPHID' => $releeph_project->getPHID(), 85 - 'branchPHID' => $branch->getPHID(), 86 - ); 87 - } 88 - 89 - $result[] = array( 90 - 'projectName' => $releeph_project->getName(), 91 - 'projectPHID' => $releeph_project->getPHID(), 92 - 'branches' => $releeph_branches_struct, 93 - 'fields' => $fields_info, 94 - ); 95 - } 96 - 97 - return $result; 98 - } 99 - 100 - }
+2 -2
src/applications/releeph/controller/branch/ReleephBranchNamePreviewController.php
··· 13 13 $template = ReleephBranchTemplate::getDefaultTemplate(); 14 14 } 15 15 16 - $arc_project_id = $request->getInt('arcProjectID'); 16 + $repository_phid = $request->getInt('repositoryPHID'); 17 17 $fake_commit_handle = 18 18 ReleephBranchTemplate::getFakeCommitHandleFor( 19 - $arc_project_id, 19 + $repository_phid, 20 20 $request->getUser()); 21 21 22 22 list($name, $errors) = id(new ReleephBranchTemplate())
+22 -58
src/applications/releeph/controller/product/ReleephProductCreateController.php
··· 6 6 $request = $this->getRequest(); 7 7 $name = trim($request->getStr('name')); 8 8 $trunk_branch = trim($request->getStr('trunkBranch')); 9 - $arc_pr_id = $request->getInt('arcPrID'); 10 - 11 - $arc_projects = $this->loadArcProjects(); 9 + $repository_phid = $request->getStr('repositoryPHID'); 12 10 13 11 $e_name = true; 14 12 $e_trunk_branch = true; ··· 27 25 'You must specify which branch you will be picking from.'); 28 26 } 29 27 30 - $arc_project = $arc_projects[$arc_pr_id]; 31 - $pr_repository = null; 32 - if ($arc_project->getRepositoryID()) { 33 - $pr_repository = id(new PhabricatorRepositoryQuery()) 34 - ->setViewer($request->getUser()) 35 - ->withIDs(array($arc_project->getRepositoryID())) 36 - ->executeOne(); 37 - } 28 + $pr_repository = id(new PhabricatorRepositoryQuery()) 29 + ->setViewer($request->getUser()) 30 + ->withPHIDs(array($repository_phid)) 31 + ->executeOne(); 38 32 39 33 40 34 if (!$errors) { ··· 42 36 ->setName($name) 43 37 ->setTrunkBranch($trunk_branch) 44 38 ->setRepositoryPHID($pr_repository->getPHID()) 45 - ->setArcanistProjectID($arc_project->getID()) 46 39 ->setCreatedByUserPHID($request->getUser()->getPHID()) 47 40 ->setIsActive(1); 48 41 ··· 58 51 } 59 52 } 60 53 61 - $arc_project_options = $this->getArcProjectSelectOptions($arc_projects); 54 + $repo_options = $this->getRepositorySelectOptions(); 62 55 63 56 $product_name_input = id(new AphrontFormTextControl()) 64 57 ->setLabel(pht('Name')) ··· 68 61 ->setError($e_name) 69 62 ->setCaption(pht('A name like "Thrift" but not "Thrift releases".')); 70 63 71 - $arc_project_input = id(new AphrontFormSelectControl()) 72 - ->setLabel(pht('Arc Project')) 73 - ->setName('arcPrID') 74 - ->setValue($arc_pr_id) 75 - ->setCaption(pht( 76 - "If your Arc project isn't listed, associate it with a repository %s.", 77 - phutil_tag( 78 - 'a', 79 - array( 80 - 'href' => '/repository/', 81 - 'target' => '_blank', 82 - ), 83 - 'here'))) 84 - ->setOptions($arc_project_options); 64 + $repository_input = id(new AphrontFormSelectControl()) 65 + ->setLabel(pht('Repository')) 66 + ->setName('repositoryPHID') 67 + ->setValue($repository_phid) 68 + ->setOptions($repo_options); 85 69 86 70 $branch_name_preview = id(new ReleephBranchPreviewView()) 87 71 ->setLabel(pht('Example Branch')) 88 72 ->addControl('projectName', $product_name_input) 89 - ->addControl('arcProjectID', $arc_project_input) 73 + ->addControl('repositoryPHID', $repository_input) 90 74 ->addStatic('template', '') 91 75 ->addStatic('isSymbolic', false); 92 76 93 77 $form = id(new AphrontFormView()) 94 78 ->setUser($request->getUser()) 95 79 ->appendChild($product_name_input) 96 - ->appendChild($arc_project_input) 80 + ->appendChild($repository_input) 97 81 ->appendChild( 98 82 id(new AphrontFormTextControl()) 99 83 ->setLabel(pht('Trunk')) ··· 126 110 )); 127 111 } 128 112 129 - private function loadArcProjects() { 130 - $viewer = $this->getRequest()->getUser(); 131 - 132 - $projects = id(new PhabricatorRepositoryArcanistProjectQuery()) 133 - ->setViewer($viewer) 134 - ->needRepositories(true) 113 + private function getRepositorySelectOptions() { 114 + $repos = id(new PhabricatorRepositoryQuery()) 115 + ->setViewer($this->getRequest()->getUser()) 135 116 ->execute(); 136 117 137 - $projects = mfilter($projects, 'getRepository'); 138 - $projects = msort($projects, 'getName'); 139 - 140 - return $projects; 141 - } 142 - 143 - private function getArcProjectSelectOptions(array $arc_projects) { 144 - assert_instances_of($arc_projects, 'PhabricatorRepositoryArcanistProject'); 145 - 146 - $repos = mpull($arc_projects, 'getRepository'); 118 + $repos = msort($repos, 'getName'); 147 119 $repos = mpull($repos, null, 'getID'); 148 120 149 - $groups = array(); 150 - foreach ($arc_projects as $arc_project) { 151 - $id = $arc_project->getID(); 152 - $repo_id = $arc_project->getRepository()->getID(); 153 - $groups[$repo_id][$id] = $arc_project->getName(); 154 - } 155 - 156 121 $choices = array(); 157 - foreach ($groups as $repo_id => $group) { 158 - $repo_name = $repos[$repo_id]->getName(); 159 - $callsign = $repos[$repo_id]->getCallsign(); 160 - $name = "r{$callsign} ({$repo_name})"; 161 - $choices[$name] = $group; 122 + 123 + foreach ($repos as $repo_id => $repo) { 124 + $repo_name = $repo->getName(); 125 + $callsign = $repo->getCallsign(); 126 + $choices[$repo->getPHID()] = "r{$callsign} ({$repo_name})"; 162 127 } 163 128 164 129 ksort($choices); 165 - 166 130 return $choices; 167 131 } 168 132
+7 -7
src/applications/releeph/controller/product/ReleephProductEditController.php
··· 15 15 $product = id(new ReleephProductQuery()) 16 16 ->setViewer($viewer) 17 17 ->withIDs(array($this->productID)) 18 - ->needArcanistProjects(true) 19 18 ->requireCapabilities( 20 19 array( 21 20 PhabricatorPolicyCapability::CAN_VIEW, ··· 48 47 $test_paths = $product->getDetail('testPaths', array()); 49 48 } 50 49 51 - $arc_project_id = $product->getArcanistProjectID(); 50 + $repository_phid = $product->getRepositoryPHID(); 52 51 53 52 if ($request->isFormPost()) { 54 53 $pusher_phids = $request->getArr('pushers'); ··· 92 91 ->setDetail('branchTemplate', $branch_template) 93 92 ->setDetail('testPaths', $test_paths); 94 93 95 - $fake_commit_handle = 96 - ReleephBranchTemplate::getFakeCommitHandleFor($arc_project_id, $viewer); 94 + $fake_commit_handle = ReleephBranchTemplate::getFakeCommitHandleFor( 95 + $repository_phid, 96 + $viewer); 97 97 98 98 if ($branch_template) { 99 99 list($branch_name, $template_errors) = id(new ReleephBranchTemplate()) ··· 136 136 $product->getRepository()->getName())) 137 137 ->appendChild( 138 138 id(new AphrontFormStaticControl()) 139 - ->setLabel(pht('Arc Project')) 139 + ->setLabel(pht('Repository')) 140 140 ->setValue( 141 - $product->getArcanistProject()->getName())) 141 + $product->getRepository()->getName())) 142 142 ->appendChild( 143 143 id(new AphrontFormStaticControl()) 144 144 ->setLabel(pht('Releeph Project PHID')) ··· 179 179 $branch_template_preview = id(new ReleephBranchPreviewView()) 180 180 ->setLabel(pht('Preview')) 181 181 ->addControl('template', $branch_template_input) 182 - ->addStatic('arcProjectID', $arc_project_id) 182 + ->addStatic('repositoryPHID', $repository_phid) 183 183 ->addStatic('isSymbolic', false) 184 184 ->addStatic('projectName', $product->getName()); 185 185
+5 -6
src/applications/releeph/controller/request/ReleephRequestDifferentialCreateController.php
··· 25 25 } 26 26 $this->revision = $diff_rev; 27 27 28 - $arc_project = id(new PhabricatorRepositoryArcanistProject()) 29 - ->loadOneWhere('phid = %s', $this->revision->getArcanistProjectPHID()); 28 + $repository = $this->revision->getRepository(); 30 29 31 30 $projects = id(new ReleephProject())->loadAllWhere( 32 - 'arcanistProjectID = %d AND isActive = 1', 33 - $arc_project->getID()); 31 + 'repositoryPHID = %s AND isActive = 1', 32 + $repository->getPHID()); 34 33 if (!$projects) { 35 34 throw new Exception( 36 35 pht( 37 - "%s belongs to the '%s' Arcanist project, ". 36 + "%s belongs to the '%s' repository, ". 38 37 "which is not part of any Releeph project!", 39 38 'D'.$this->revision->getID(), 40 - $arc_project->getName())); 39 + $repository->getMonogram())); 41 40 } 42 41 43 42 $branches = id(new ReleephBranch())->loadAllWhere(
-28
src/applications/releeph/query/ReleephProductQuery.php
··· 8 8 private $phids; 9 9 private $repositoryPHIDs; 10 10 11 - private $needArcanistProjects; 12 - 13 11 const ORDER_ID = 'order-id'; 14 12 const ORDER_NAME = 'order-name'; 15 13 ··· 44 42 45 43 public function withRepositoryPHIDs(array $repository_phids) { 46 44 $this->repositoryPHIDs = $repository_phids; 47 - return $this; 48 - } 49 - 50 - public function needArcanistProjects($need) { 51 - $this->needArcanistProjects = $need; 52 45 return $this; 53 46 } 54 47 ··· 88 81 } 89 82 90 83 return $projects; 91 - } 92 - 93 - protected function didFilterPage(array $products) { 94 - if ($this->needArcanistProjects) { 95 - $project_ids = array_filter(mpull($products, 'getArcanistProjectID')); 96 - if ($project_ids) { 97 - $projects = id(new PhabricatorRepositoryArcanistProject()) 98 - ->loadAllWhere('id IN (%Ld)', $project_ids); 99 - $projects = mpull($projects, null, 'getID'); 100 - } else { 101 - $projects = array(); 102 - } 103 - 104 - foreach ($products as $product) { 105 - $project_id = $product->getArcanistProjectID(); 106 - $project = idx($projects, $project_id); 107 - $product->attachArcanistProject($project); 108 - } 109 - } 110 - 111 - return $products; 112 84 } 113 85 114 86 protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
+1 -7
src/applications/releeph/query/ReleephProductSearchEngine.php
··· 21 21 22 22 public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) { 23 23 $query = id(new ReleephProductQuery()) 24 - ->setOrder(ReleephProductQuery::ORDER_NAME) 25 - ->needArcanistProjects(true); 24 + ->setOrder(ReleephProductQuery::ORDER_NAME); 26 25 27 26 $active = $saved->getParameter('active'); 28 27 $value = idx($this->getActiveValues(), $active); ··· 118 117 'href' => '/diffusion/'.$repo->getCallsign().'/', 119 118 ), 120 119 'r'.$repo->getCallsign())); 121 - 122 - $arc = $product->getArcanistProject(); 123 - if ($arc) { 124 - $item->addAttribute($arc->getName()); 125 - } 126 120 127 121 $list->addItem($item); 128 122 }
+4 -4
src/applications/releeph/view/branch/ReleephBranchPreviewView.php
··· 24 24 25 25 protected function renderInput() { 26 26 static $required_params = array( 27 - 'arcProjectID', 27 + 'repositoryPHID', 28 28 'projectName', 29 29 'isSymbolic', 30 30 'template', ··· 43 43 $output_id = celerity_generate_unique_node_id(); 44 44 45 45 Javelin::initBehavior('releeph-preview-branch', array( 46 - 'uri' => '/releeph/branch/preview/', 47 - 'outputID' => $output_id, 48 - 'params' => array( 46 + 'uri' => '/releeph/branch/preview/', 47 + 'outputID' => $output_id, 48 + 'params' => array( 49 49 'static' => $this->statics, 50 50 'dynamic' => $this->dynamics, 51 51 ),
+5 -16
src/applications/releeph/view/branch/ReleephBranchTemplate.php
··· 20 20 } 21 21 22 22 public static function getFakeCommitHandleFor( 23 - $arc_project_id, 23 + $repository_phid, 24 24 PhabricatorUser $viewer) { 25 25 26 - $arc_project = id(new PhabricatorRepositoryArcanistProject()) 27 - ->load($arc_project_id); 28 - if (!$arc_project) { 29 - throw new Exception( 30 - pht( 31 - "No Arc project found with id '%s'!", 32 - $arc_project_id)); 33 - } 26 + $repository = id(new PhabricatorRepositoryQuery()) 27 + ->setViewer($viewer) 28 + ->withPHIDs(array($repository_phid)) 29 + ->executeOne(); 34 30 35 - $repository = null; 36 - if ($arc_project->getRepositoryID()) { 37 - $repository = id(new PhabricatorRepositoryQuery()) 38 - ->setViewer($viewer) 39 - ->withIDs(array($arc_project->getRepositoryID())) 40 - ->executeOne(); 41 - } 42 31 $fake_handle = 'SOFAKE'; 43 32 if ($repository) { 44 33 $fake_handle = id(new PhabricatorObjectHandle())