summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-05-06 04:20:35 +0000
committerGerrit Code Review <review@openstack.org>2015-05-06 04:20:36 +0000
commit44ee5f0d0cb5a0290534b06298bb598142425b1e (patch)
tree9471f32a9d3364d223dfcd7a559c99dde7e0f3e7
parent8c22c67bdafbe44e1c5779fdc35befd045c3acc5 (diff)
parentd689d9af9c22952ac0fc3054944e8024eb757ff8 (diff)
downloadpbr-44ee5f0d0cb5a0290534b06298bb598142425b1e.tar.gz
Merge "Issue #1451976: handle commits with non-utf8 text"
-rw-r--r--pbr/git.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/pbr/git.py b/pbr/git.py
index a64661f..ac9ccb1 100644
--- a/pbr/git.py
+++ b/pbr/git.py
@@ -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]