# HG changeset patch # User Milka Kuzminski # Date 2021-03-18 14:26:51 # Node ID 8a9c9ffb290ff7e60e3aa3e31b88211bbf5fee82 # Parent 149be224f5d41dc519a89f096760adc7ed47e905 git: fix for unicode branches diff --git a/rhodecode/apps/repository/views/repo_changelog.py b/rhodecode/apps/repository/views/repo_changelog.py --- a/rhodecode/apps/repository/views/repo_changelog.py +++ b/rhodecode/apps/repository/views/repo_changelog.py @@ -34,7 +34,7 @@ from rhodecode.lib.auth import ( from rhodecode.lib.ext_json import json from rhodecode.lib.graphmod import _colored, _dagwalker from rhodecode.lib.helpers import RepoPage -from rhodecode.lib.utils2 import safe_int, safe_str, str2bool +from rhodecode.lib.utils2 import safe_int, safe_str, str2bool, safe_unicode from rhodecode.lib.vcs.exceptions import ( RepositoryError, CommitDoesNotExistError, CommitError, NodeDoesNotExistError, EmptyRepositoryError) @@ -110,7 +110,7 @@ class RepoChangelogView(RepoAppView): def _check_if_valid_branch(self, branch_name, repo_name, f_path): if branch_name not in self.rhodecode_vcs_repo.branches_all: - h.flash('Branch {} is not found.'.format(h.escape(branch_name)), + h.flash(u'Branch {} is not found.'.format(h.escape(safe_unicode(branch_name))), category='warning') redirect_url = h.route_path( 'repo_commits_file', repo_name=repo_name, 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 @@ -98,7 +98,7 @@ class GitCommit(base.BaseCommit): elif attr == "parents": value = self._make_commits(value) elif attr == "branch": - value = value[0] if value else None + value = self._set_branch(value) self.__dict__[attr] = value @LazyProperty @@ -156,13 +156,15 @@ class GitCommit(base.BaseCommit): branches.append(name) return branches + def _set_branch(self, branches): + if branches: + # actually commit can have multiple branches in git + return safe_unicode(branches[0]) + @LazyProperty def branch(self): branches = self._remote.branch(self.raw_id) - - if branches: - # actually commit can have multiple branches in git - return safe_unicode(branches[0]) + return self._set_branch(branches) def _get_tree_id_for_path(self, path): path = safe_str(path)