Changeset - eb1182919890
[Not reviewed]
default
0 2 0
domruf - 8 years ago 2017-11-20 23:18:38
dominikruf@gmail.com
Grafted from: 35f75876280c
git: fix URL for submodules - make it link to the external URL

Without this changeset, the link on the files page would not point to the
submodule target. Instead it would simple point to ./<submodulename>, which when
clicked leads to a '500 Internal Server Error'.
2 files changed with 10 insertions and 4 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/vcs/backends/git/changeset.py
Show inline comments
 
import re
 
from itertools import chain
 
from dulwich import objects
 
from dulwich.config import ConfigFile
 
from subprocess import Popen, PIPE
 
from io import BytesIO
 

	
 
from kallithea.lib.vcs.conf import settings
 
from kallithea.lib.vcs.backends.base import BaseChangeset, EmptyChangeset
 
@@ -409,7 +411,9 @@ class GitChangeset(BaseChangeset):
 
        als = self.repository.alias
 
        for name, stat, id in tree.iteritems():
 
            if objects.S_ISGITLINK(stat):
 
                dirnodes.append(SubModuleNode(name, url=None, changeset=id,
 
                cf = ConfigFile.from_file(BytesIO(self.repository._repo.get_object(tree['.gitmodules'][1]).data))
 
                url = cf.get(('submodule', name), 'url')
 
                dirnodes.append(SubModuleNode(name, url=url, changeset=id,
 
                                              alias=als))
 
                continue
 

	
 
@@ -447,7 +451,10 @@ class GitChangeset(BaseChangeset):
 

	
 
            _GL = lambda m: m and objects.S_ISGITLINK(m)
 
            if _GL(self._stat_modes.get(path)):
 
                node = SubModuleNode(path, url=None, changeset=id_,
 
                tree = self.repository._repo[self._tree_id]
 
                cf = ConfigFile.from_file(BytesIO(self.repository._repo.get_object(tree['.gitmodules'][1]).data))
 
                url = cf.get(('submodule', path), 'url')
 
                node = SubModuleNode(path, url=url, changeset=id_,
 
                                     alias=self.repository.alias)
 
            else:
 
                obj = self.repository._repo.get_object(id_)
kallithea/tests/other/test_vcs_operations.py
Show inline comments
 
@@ -688,8 +688,7 @@ class TestVCSOperations(TestController):
 
                                    repo_name=fork_name,
 
                                    revision='tip',
 
                                    f_path='/'))
 
        # BUG: the link to testsubmodule doesn't work - it should probably point at the submodule URL
 
        response.mustcontain('<a class="submodule-dir" href="testsubmodule"><i class="icon-file-submodule"></i><span>testsubmodule @ ')
 
        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',
0 comments (0 inline, 0 general)