aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2017-11-06 19:22:03 +0100
committerGuido Günther <agx@sigxcpu.org>2017-11-06 19:27:52 +0100
commit1590ec85030f6ed71b4a69bf22b0e9944ca06a7a (patch)
treed3a6909f6b9a6d22ded31c61d5f4f30119a9b1d5
parent031910888f8d1d407a7c4b8e838cf596c336327b (diff)
pq: Make sure apply_and_commit_patch encodes the author utf-8
Git itself doesn't care but Python wants a bytestring. This only matters when using the C locale. We delay conversion so we don't have to handle fallback_author separately. We can't convert unconditionally since pq-rpm is allowed to pass in a None author.
-rw-r--r--gbp/scripts/common/pq.py6
-rw-r--r--tests/13_test_gbp_pq.py3
2 files changed, 7 insertions, 2 deletions
diff --git a/gbp/scripts/common/pq.py b/gbp/scripts/common/pq.py
index 744c1f03..004c231b 100644
--- a/gbp/scripts/common/pq.py
+++ b/gbp/scripts/common/pq.py
@@ -315,7 +315,9 @@ def apply_and_commit_patch(repo, patch, fallback_author, topic=None, name=None):
patch_fn = os.path.basename(patch.path)
if not (author['name'] and author['email']):
if fallback_author and fallback_author['name']:
- author = fallback_author
+ author = {}
+ for key in 'name', 'email', 'date':
+ author[key] = fallback_author.get(key)
gbp.log.warn("Patch '%s' has no authorship information, using "
"'%s <%s>'" % (patch_fn, author['name'],
author['email']))
@@ -333,6 +335,8 @@ def apply_and_commit_patch(repo, patch, fallback_author, topic=None, name=None):
msg += "\nGbp-Pq: Topic %s" % topic
if name:
msg += "\nGbp-Pq: Name %s" % name
+ if author['name']:
+ author['name'] = author['name'].encode('utf-8')
commit = repo.commit_tree(tree, msg, [repo.head], author=author)
repo.update_ref('HEAD', commit, msg="gbp-pq import %s" % patch.path)
diff --git a/tests/13_test_gbp_pq.py b/tests/13_test_gbp_pq.py
index 2e9f8a60..5f4668b6 100644
--- a/tests/13_test_gbp_pq.py
+++ b/tests/13_test_gbp_pq.py
@@ -95,7 +95,8 @@ class TestApplyAndCommit(testutils.DebianGitTestRepo):
# Fake a control file
self.add_file("debian/control",
- "Maintainer: Guido Günther <gg@godiug.net>")
+ "Maintainer: Guido Günther <gg@godiug.net>".encode('utf-8'),
+ mode='wb+')
maintainer = pq.get_maintainer_from_control(self.repo)
orig_warn = gbp.log.warn