← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~wgrant/launchpad/bug-665135-empty-remote-url into lp:launchpad

 

William Grant has proposed merging lp:~wgrant/launchpad/bug-665135-empty-remote-url into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  #665135 InvalidURIError raised rendering +code-index page
  https://bugs.launchpad.net/bugs/665135

For more details, see:
https://code.launchpad.net/~wgrant/launchpad/bug-665135-empty-remote-url/+merge/47761

Projects with a remote development focus branch with no URL (eg. https://code.launchpad.net/phpldapadmin) currently OOPS. This occurs because the page attempts to verify whether the URL's domain is blacklisted, and None doesn't parse too well as a URL.

This branch fixes the check to always let through None, and adds a test that this works.
-- 
https://code.launchpad.net/~wgrant/launchpad/bug-665135-empty-remote-url/+merge/47761
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/bug-665135-empty-remote-url into lp:launchpad.
=== modified file 'lib/lp/code/browser/branch.py'
--- lib/lp/code/browser/branch.py	2010-12-21 00:45:30 +0000
+++ lib/lp/code/browser/branch.py	2011-01-28 02:33:42 +0000
@@ -408,7 +408,7 @@
         branch = self.branch
 
         # If the user has edit permissions, then show the actual location.
-        if check_permission('launchpad.Edit', branch):
+        if branch.url is None or check_permission('launchpad.Edit', branch):
             return branch.url
 
         # XXX: Tim Penhey, 2008-05-30

=== modified file 'lib/lp/code/browser/tests/test_branch.py'
--- lib/lp/code/browser/tests/test_branch.py	2010-12-14 21:15:31 +0000
+++ lib/lp/code/browser/tests/test_branch.py	2011-01-28 02:33:42 +0000
@@ -82,6 +82,16 @@
         self.assertEqual(
             "http://example.com/good/mirror";, view.mirror_location)
 
+    def testLocationlessRemoteBranch(self):
+        # A branch from a normal location is fine.
+        branch = self.factory.makeAnyBranch(
+            branch_type=BranchType.REMOTE,
+            url=None)
+        view = BranchView(branch, LaunchpadTestRequest())
+        view.initialize()
+        self.assertTrue(view.user is None)
+        self.assertIs(None, view.mirror_location)
+
     def testHiddenBranchAsAnonymous(self):
         # A branch location with a defined private host is hidden from
         # anonymous browsers.