diff options
author | Robert Collins <rbtcollins@hp.com> | 2015-05-06 06:37:30 +1200 |
---|---|---|
committer | Robert Collins <rbtcollins@hp.com> | 2015-05-06 06:37:30 +1200 |
commit | d689d9af9c22952ac0fc3054944e8024eb757ff8 (patch) | |
tree | f806c1538d2edd8fc054f461be5e579eec19234e | |
parent | cfd8ab2dec5cb85cb2de74a7ee3c5c6195f6b12b (diff) | |
download | pbr-d689d9af9c22952ac0fc3054944e8024eb757ff8.tar.gz |
Issue #1451976: handle commits with non-utf8 text
History may have commits with non utf8 text in them. Rather than
forcing users to rebase, handle it gracefully.
Change-Id: I6f6302c815b02234e27ee31f7ce87eab101b40ea
Closes-Bug: #1451976
-rw-r--r-- | pbr/git.py | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -50,7 +50,9 @@ def _run_shell_command(cmd, throw_on_error=False, buffer=True, env=None): "%s returned %d" % (cmd, output.returncode)) if len(out) == 0 or not out[0] or not out[0].strip(): return '' - return out[0].strip().decode('utf-8') + # Since we don't control the history, and forcing users to rebase arbitrary + # history to fix utf8 issues is harsh, decode with replace. + return out[0].strip().decode('utf-8', 'replace') def _run_git_command(cmd, git_dir, **kwargs): @@ -96,6 +98,8 @@ def _find_git_files(dirname='', git_dir=None): if git_dir: log.info("[pbr] In git context, generating filelist from git") file_list = _run_git_command(['ls-files', '-z'], git_dir) + # Users can fix utf8 issues locally with a single commit, so we are + # strict here. file_list = file_list.split(b'\x00'.decode('utf-8')) return [f for f in file_list if f] |