# HG changeset patch # User RhodeCode Admin # Date 2023-08-07 12:01:30 # Node ID de59bf7001cd1634393e2847f873ecee8bac75a4 # Parent d0f694ba3b24993f084c9d3ba86635f458e68b16 git: fix submodule handling for git repositories diff --git a/rhodecode/lib/vcs/backends/git/commit.py b/rhodecode/lib/vcs/backends/git/commit.py --- a/rhodecode/lib/vcs/backends/git/commit.py +++ b/rhodecode/lib/vcs/backends/git/commit.py @@ -20,6 +20,7 @@ GIT commit module """ +import io import stat import configparser from itertools import chain @@ -309,16 +310,16 @@ class GitCommit(base.BaseCommit): filenodes = [] # extracted tree ID gives us our files... - bytes_path = safe_str(path) # libgit operates on bytes + str_path = safe_str(path) # libgit operates on bytes for name, stat_, id_, type_ in self._remote.tree_items(tree_id): if type_ == 'link': - url = self._get_submodule_url('/'.join((bytes_path, name))) + url = self._get_submodule_url('/'.join((str_path, name))) dirnodes.append(SubModuleNode( name, url=url, commit=id_, alias=self.repository.alias)) continue - if bytes_path != '': - obj_path = '/'.join((bytes_path, name)) + if str_path != '': + obj_path = '/'.join((str_path, name)) else: obj_path = name if obj_path not in self._stat_modes: @@ -471,13 +472,8 @@ class GitCommit(base.BaseCommit): except NodeDoesNotExistError: return None - # ConfigParser fails if there are whitespaces, also it needs an iterable - # file like content - def iter_content(_content): - yield from _content.splitlines() - parser = configparser.RawConfigParser() - parser.read_file(iter_content(submodules_node.content)) + parser.read_file(io.StringIO(submodules_node.str_content)) for section in parser.sections(): path = parser.get(section, 'path')