You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2013/07/02 04:03:57 UTC

[2/5] git commit: [#6056] Fixed KeyError when browsing invalid trees in SCM

[#6056] Fixed KeyError when browsing invalid trees in SCM

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/df543a1b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/df543a1b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/df543a1b

Branch: refs/heads/cj/6056
Commit: df543a1b616e08f8aa08d77d7d7be42512ffc932
Parents: 2e25a0e
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Mon Jul 1 21:49:25 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Mon Jul 1 21:49:25 2013 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/repository.py                | 5 +++--
 ForgeGit/forgegit/tests/functional/test_controllers.py | 7 +++++++
 2 files changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/df543a1b/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index 4f6122d..c8d852b 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -548,8 +548,9 @@ class TreeBrowser(BaseController, DispatchIndex):
                         filename), rest
         elif rest == ('index', ):
             rest = (request.environ['PATH_INFO'].rsplit('/')[-1],)
-        tree = self._tree[next]
-        if tree is None:
+        try:
+            tree = self._tree[next]
+        except KeyError:
             raise exc.HTTPNotFound
         return self.__class__(
             self._commit,

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/df543a1b/ForgeGit/forgegit/tests/functional/test_controllers.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/functional/test_controllers.py b/ForgeGit/forgegit/tests/functional/test_controllers.py
index c4ac325..3304625 100644
--- a/ForgeGit/forgegit/tests/functional/test_controllers.py
+++ b/ForgeGit/forgegit/tests/functional/test_controllers.py
@@ -205,6 +205,13 @@ class TestRootController(_TestCase):
         resp = self.app.get(ci + 'tree/?format=raw')
         assert 'README' in resp, resp.showbrowser()
 
+    def test_tree_invalid(self):
+        ci = self._get_ci()
+        resp = self.app.get(ci + 'tree/foo', status=404)
+        assert_equal(resp.status_int, 404)
+        resp = self.app.get(ci + 'tree/foo/bar', status=404)
+        assert_equal(resp.status_int, 404)
+
     def test_file(self):
         ci = self._get_ci()
         resp = self.app.get(ci + 'tree/README')