allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [1/6] git commit: [#5120] ticket:307 beautiful urls only for branch browser
Date Wed, 03 Apr 2013 22:20:00 GMT
Updated Branches:
  refs/heads/master f81ebb34c -> 4c3419a57


[#5120] ticket:307 beautiful urls only for branch browser


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

Branch: refs/heads/master
Commit: c82342121105e8fd5c6a793a22a9b31caba5e83c
Parents: 55aba26
Author: Yuriy Arhipov <yuriyarhipovua@yandex.ru>
Authored: Mon Apr 1 16:58:11 2013 +0400
Committer: Cory Johns <cjohns@slashdotmedia.com>
Committed: Wed Apr 3 22:16:57 2013 +0000

----------------------------------------------------------------------
 Allura/allura/model/repository.py                |   12 ++++++++++--
 ForgeGit/forgegit/controllers.py                 |    2 +-
 ForgeGit/forgegit/tests/model/test_repository.py |    9 +++++----
 ForgeSVN/forgesvn/controllers.py                 |    2 +-
 ForgeSVN/forgesvn/model/svn.py                   |   10 +++++++++-
 ForgeSVN/forgesvn/tests/model/test_repository.py |    4 ++--
 6 files changed, 28 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c8234212/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 36781d6..f33d446 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -158,8 +158,7 @@ class RepositoryImplementation(object):
         tags = [t.name for t in self._repo.repo_tags if t.object_id == commit._id]
         return branches, tags
 
-    def url_for_commit(self, commit):
-        'return an URL, given either a commit or object id'
+    def url_for_symbolic(self, commit):
         if isinstance(commit, basestring):
             object_id = commit
         else:
@@ -185,6 +184,15 @@ class RepositoryImplementation(object):
 
         return '%sci/%s/' % (self._repo.url(), object_id)
 
+    def url_for_commit(self, commit):
+        'return an URL, given either a commit or object id'
+        if isinstance(commit, basestring):
+            object_id = commit
+        else:
+            object_id = commit._id
+
+        return '%sci/%s/' % (self._repo.url(), object_id)
+
     def _setup_paths(self, create_repo_dir=True):
         '''
         Ensure that the base directory in which the repo lives exists.

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c8234212/ForgeGit/forgegit/controllers.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/controllers.py b/ForgeGit/forgegit/controllers.py
index dfc3478..4a8fab7 100644
--- a/ForgeGit/forgegit/controllers.py
+++ b/ForgeGit/forgegit/controllers.py
@@ -12,5 +12,5 @@ class BranchBrowser(repository.BranchBrowser):
         latest = c.app.repo.latest(branch=self._branch)
         if not latest:
             return dict(allow_fork=False, log=[])
-        redirect(latest.url() + 'tree/')
+        redirect(c.app.repo._impl.url_for_symbolic(latest._id) + 'tree/')
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c8234212/ForgeGit/forgegit/tests/model/test_repository.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/model/test_repository.py b/ForgeGit/forgegit/tests/model/test_repository.py
index 26c952f..5e771dc 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -59,7 +59,7 @@ class TestNewGit(unittest.TestCase):
         assert self.rev.symbolic_ids == (['master', 'zz'], [])
         assert self.rev.url() == (
             '/p/test/src-git/ci/'
-            'master/')
+            '1e146e67985dcd71c74de79613719bef7bddca4a/')
         all_cis = self.repo.log(self.rev._id, 0, 1000)
         assert len(all_cis) == 4
         assert_equal(self.repo.log(self.rev._id, 1,1000), all_cis[1:])
@@ -74,7 +74,7 @@ class TestNewGit(unittest.TestCase):
         assert self.rev.tree.path() == '/'
         assert self.rev.tree.url() == (
             '/p/test/src-git/ci/'
-            'master/'
+            '1e146e67985dcd71c74de79613719bef7bddca4a/'
             'tree/')
         self.rev.tree.by_name['README']
         assert self.rev.tree.is_blob('README') == True
@@ -91,7 +91,7 @@ class TestNewGit(unittest.TestCase):
             assert ci.shorthand_id() == '[1e146e]', ci.shorthand_id()
             assert ci.url() == (
                 '/p/test/src-git/ci/'
-                'master/')
+                '1e146e67985dcd71c74de79613719bef7bddca4a/')
 
 class TestGitRepo(unittest.TestCase, RepoImplTestBase):
 
@@ -315,7 +315,8 @@ class TestGitCommit(unittest.TestCase):
         ThreadLocalORMSession.close_all()
 
     def test_url(self):
-        assert self.rev.url().endswith('master/'), self.rev.url()
+        assert self.rev.url().endswith('ca4a/')
+        assert self.repo._impl.url_for_symbolic(self.rev._id).endswith('master/'), self.repo._impl.url_for_symbolic(self.rev._id)
 
     def test_committer_url(self):
         assert self.rev.committer_url is None

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c8234212/ForgeSVN/forgesvn/controllers.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/controllers.py b/ForgeSVN/forgesvn/controllers.py
index 59748ec..0a87b40 100644
--- a/ForgeSVN/forgesvn/controllers.py
+++ b/ForgeSVN/forgesvn/controllers.py
@@ -16,7 +16,7 @@ class BranchBrowser(repository.BranchBrowser):
         latest = c.app.repo.latest(branch=self._branch)
         if not latest or (latest._id.split(':')[1] == '1' and h.has_access(c.app, 'write')()):
             return dict(allow_fork=False, log=[])
-        redirect(latest.url() + 'tree/')
+        redirect(c.app.repo._impl.url_for_symbolic(latest._id) + 'tree/')
 
     @expose()
     def _lookup(self, rev, *remainder):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c8234212/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index 30fb655..2e18b2c 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -162,7 +162,7 @@ class SVNImplementation(M.RepositoryImplementation):
     def shorthand_for_commit(self, oid):
         return '[r%d]' % self._revno(oid)
 
-    def url_for_commit(self, commit):
+    def url_for_symbolic(self, commit):
         if isinstance(commit, basestring):
             object_id = commit
         else:
@@ -172,6 +172,14 @@ class SVNImplementation(M.RepositoryImplementation):
         return '%s%d/' % (
             self._repo.url(), self._revno(object_id))
 
+    def url_for_commit(self, commit):
+        if isinstance(commit, basestring):
+            object_id = commit
+        else:
+            object_id = commit._id
+        return '%s%d/' % (
+            self._repo.url(), self._revno(object_id))
+
     def init(self, default_dirs=True, skip_special_files=False):
         fullname = self._setup_paths()
         log.info('svn init %s', fullname)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c8234212/ForgeSVN/forgesvn/tests/model/test_repository.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/tests/model/test_repository.py b/ForgeSVN/forgesvn/tests/model/test_repository.py
index 077c50a..1613cf9 100644
--- a/ForgeSVN/forgesvn/tests/model/test_repository.py
+++ b/ForgeSVN/forgesvn/tests/model/test_repository.py
@@ -63,7 +63,7 @@ class TestNewRepo(unittest.TestCase):
         assert self.rev.shorthand_id() == '[r5]'
         assert self.rev.symbolic_ids == ([], [])
         assert self.rev.url() == (
-            '/p/test/src/HEAD/')
+            '/p/test/src/5/')
         all_cis = self.repo.log(self.rev._id, 0, 1000)
         assert len(all_cis) == 5
         assert self.repo.log(self.rev._id, 1,1000) == all_cis[1:]
@@ -76,7 +76,7 @@ class TestNewRepo(unittest.TestCase):
             'README', 'This is readme\nAnother Line\n')
         assert self.rev.tree.path() == '/'
         assert self.rev.tree.url() == (
-            '/p/test/src/HEAD/tree/')
+            '/p/test/src/5/tree/')
         self.rev.tree.by_name['README']
         assert self.rev.tree.is_blob('README') == True
         assert self.rev.tree['a']['b']['c'].ls() == []


Mime
View raw message