From 05e30a024d86545bd34641d945c0a58e76df2303 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 14 Apr 2014 12:07:14 -0700 Subject: [PATCH] Unban releeph product name "branch" Summary: Fixes T3657. We no longer construct ambiguous URIs, so product names are no longer restricted. Also fix some minor URI construction stuff. Test Plan: Created a product called "branch". Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T3657 Differential Revision: https://secure.phabricator.com/D8767 --- .../PhabricatorApplicationReleeph.php | 2 +- .../branch/ReleephBranchCreateController.php | 4 +++- .../branch/ReleephBranchViewController.php | 16 +++++++++------- .../releeph/storage/ReleephProject.php | 19 ------------------- 4 files changed, 13 insertions(+), 28 deletions(-) diff --git a/src/applications/releeph/application/PhabricatorApplicationReleeph.php b/src/applications/releeph/application/PhabricatorApplicationReleeph.php index 347e783892..f44a74249e 100644 --- a/src/applications/releeph/application/PhabricatorApplicationReleeph.php +++ b/src/applications/releeph/application/PhabricatorApplicationReleeph.php @@ -58,7 +58,7 @@ final class PhabricatorApplicationReleeph extends PhabricatorApplication { '(?Pclose|re-open)/(?P[1-9]\d*)/' => 'ReleephBranchAccessController', 'preview/' => 'ReleephBranchNamePreviewController', - '(?P[^/]+)/' => array( + '(?P[1-9]\d*)/' => array( 'history/' => 'ReleephBranchHistoryController', '(?:query/(?P[^/]+)/)?' => 'ReleephBranchViewController', ), diff --git a/src/applications/releeph/controller/branch/ReleephBranchCreateController.php b/src/applications/releeph/controller/branch/ReleephBranchCreateController.php index e6725974c9..bc6cca3877 100644 --- a/src/applications/releeph/controller/branch/ReleephBranchCreateController.php +++ b/src/applications/releeph/controller/branch/ReleephBranchCreateController.php @@ -79,8 +79,10 @@ final class ReleephBranchCreateController extends ReleephProductController { $branch_date, $symbolic_name); + $branch_uri = $this->getApplicationURI('branch/'.$branch->getID()); + return id(new AphrontRedirectResponse()) - ->setURI($branch->getURI()); + ->setURI($branch_uri); } } diff --git a/src/applications/releeph/controller/branch/ReleephBranchViewController.php b/src/applications/releeph/controller/branch/ReleephBranchViewController.php index d7928ed95d..e0e13667df 100644 --- a/src/applications/releeph/controller/branch/ReleephBranchViewController.php +++ b/src/applications/releeph/controller/branch/ReleephBranchViewController.php @@ -86,13 +86,15 @@ final class ReleephBranchViewController extends ReleephBranchController $crumbs = parent::buildApplicationCrumbs(); $branch = $this->getBranch(); - - $crumbs->addAction( - id(new PHUIListItemView()) - ->setHref($this->getApplicationURI('branch/pull/'.$branch->getID().'/')) - ->setName(pht('New Pull Request')) - ->setIcon('create') - ->setDisabled(!$branch->isActive())); + if ($branch) { + $pull_uri = $this->getApplicationURI('branch/pull/'.$branch->getID().'/'); + $crumbs->addAction( + id(new PHUIListItemView()) + ->setHref($pull_uri) + ->setName(pht('New Pull Request')) + ->setIcon('create') + ->setDisabled(!$branch->isActive())); + } return $crumbs; } diff --git a/src/applications/releeph/storage/ReleephProject.php b/src/applications/releeph/storage/ReleephProject.php index d811f50862..84623d24ed 100644 --- a/src/applications/releeph/storage/ReleephProject.php +++ b/src/applications/releeph/storage/ReleephProject.php @@ -53,19 +53,6 @@ final class ReleephProject extends ReleephDAO return $this; } - public function willSaveObject() { - // Do this first, to generate the PHID - parent::willSaveObject(); - - $banned_names = $this->getBannedNames(); - if (in_array($this->name, $banned_names)) { - throw new Exception(sprintf( - "The name '%s' is in the list of banned project names!", - $this->name, - implode(', ', $banned_names))); - } - } - public function loadArcanistProject() { return $this->loadOneRelative( new PhabricatorRepositoryArcanistProject(), @@ -116,12 +103,6 @@ final class ReleephProject extends ReleephDAO return new ReleephDefaultFieldSelector(); } - private function getBannedNames() { - return array( - 'branch', // no one's tried this... yet! - ); - } - public function isTestFile($filename) { $test_paths = $this->getDetail('testPaths', array());