Mercurial > kallithea
changeset 7200:eb1182919890
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'.
author | domruf <dominikruf@gmail.com> |
---|---|
date | Mon, 20 Nov 2017 23:18:38 +0100 |
parents | 0bec9f92745a |
children | a8d8100f14e5 |
files | kallithea/lib/vcs/backends/git/changeset.py kallithea/tests/other/test_vcs_operations.py |
diffstat | 2 files changed, 10 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/lib/vcs/backends/git/changeset.py Mon Nov 20 23:18:38 2017 +0100 +++ b/kallithea/lib/vcs/backends/git/changeset.py Mon Nov 20 23:18:38 2017 +0100 @@ -1,7 +1,9 @@ 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 @@ 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 @@ _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_)
--- a/kallithea/tests/other/test_vcs_operations.py Mon Nov 20 23:18:38 2017 +0100 +++ b/kallithea/tests/other/test_vcs_operations.py Mon Nov 20 23:18:38 2017 +0100 @@ -688,8 +688,7 @@ 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',