diff options
Diffstat (limited to 'contrib/gcc-changelog/git_commit.py')
-rwxr-xr-x | contrib/gcc-changelog/git_commit.py | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/contrib/gcc-changelog/git_commit.py b/contrib/gcc-changelog/git_commit.py index d2e5dbe..ee19733 100755 --- a/contrib/gcc-changelog/git_commit.py +++ b/contrib/gcc-changelog/git_commit.py @@ -174,6 +174,24 @@ REVIEW_PREFIXES = ('reviewed-by: ', 'reviewed-on: ', 'signed-off-by: ', DATE_FORMAT = '%Y-%m-%d' +def decode_path(path): + # When core.quotepath is true (default value), utf8 chars are encoded like: + # "b/ko\304\215ka.txt" + # + # The upstream bug is fixed: + # https://github.com/gitpython-developers/GitPython/issues/1099 + # + # but we still need a workaround for older versions of the library. + # Please take a look at the explanation of the transformation: + # https://stackoverflow.com/questions/990169/how-do-convert-unicode-escape-sequences-to-unicode-characters-in-a-python-string + + if path.startswith('"') and path.endswith('"'): + return (path.strip('"').encode('utf8').decode('unicode-escape') + .encode('latin-1').decode('utf8')) + else: + return path + + class Error: def __init__(self, message, line=None): self.message = message @@ -303,14 +321,6 @@ class GitCommit: 'separately from normal commits')) return - # check for an encoded utf-8 filename - hint = 'git config --global core.quotepath false' - for modified, _ in self.info.modified_files: - if modified.startswith('"') or modified.endswith('"'): - self.errors.append(Error('Quoted UTF8 filename, please set: ' - f'"{hint}"', modified)) - return - all_are_ignored = (len(project_files) + len(ignored_files) == len(self.info.modified_files)) self.parse_lines(all_are_ignored) |