Changeset - 48f7c2aed3b7
[Not reviewed]
default
0 2 0
domruf - 8 years ago 2018-03-11 17:36:38
dominikruf@gmail.com
Grafted from: 35f75876280c
git: fix links to nodes that are submodule links

Without this changeset, a link pointing to ./<submodulename> would generate a
'500 Internal Server Error'.

Instead, redirect requests to submodule paths to the target URL.
2 files changed with 5 insertions and 2 deletions:
0 comments (0 inline, 0 general)
kallithea/controllers/files.py
Show inline comments
 
@@ -156,25 +156,27 @@ class FilesController(BaseRepoController
 
            next_rev = c.db_repo_scm_instance.get_changeset(cur_rev).next(c.branch)
 
            c.url_next = url('files_home', repo_name=c.repo_name,
 
                     revision=next_rev.raw_id, f_path=f_path)
 
            if c.branch:
 
                c.url_next += '?branch=%s' % c.branch
 
        except (ChangesetDoesNotExistError, VCSError):
 
            c.url_next = '#'
 

	
 
        # files or dirs
 
        try:
 
            c.file = c.changeset.get_node(f_path)
 

	
 
            if c.file.is_file():
 
            if c.file.is_submodule():
 
                raise HTTPFound(location=c.file.url)
 
            elif c.file.is_file():
 
                c.load_full_history = False
 
                # determine if we're on branch head
 
                _branches = c.db_repo_scm_instance.branches
 
                c.on_branch_head = revision in _branches.keys() + _branches.values()
 
                _hist = []
 
                c.file_history = []
 
                if c.load_full_history:
 
                    c.file_history, _hist = self._get_node_history(c.changeset, f_path)
 

	
 
                c.authors = []
 
                for a in set([x.author for x in _hist]):
 
                    c.authors.append((h.email(a), h.person(a)))
kallithea/tests/other/test_vcs_operations.py
Show inline comments
 
@@ -686,13 +686,14 @@ class TestVCSOperations(TestController):
 
        self.log_user()
 
        response = self.app.get(url(controller='files', action='index',
 
                                    repo_name=fork_name,
 
                                    revision='tip',
 
                                    f_path='/'))
 
        response.mustcontain('<a class="submodule-dir" href="%s"><i class="icon-file-submodule"></i><span>testsubmodule @ ' % clone_url)
 

	
 
        # check that following a submodule link actually works - and redirects
 
        response = self.app.get(url(controller='files', action='index',
 
                                    repo_name=fork_name,
 
                                    revision='tip',
 
                                    f_path='/testsubmodule'),
 
                                status=500) # BUG
 
                                status=302)
 
        assert response.location == clone_url
0 comments (0 inline, 0 general)