devtools: Fix utf-8 support in messages for github-merge

Use 'utf-8' instead of the Python 2 default of 'ascii' to encode/decode
commit messages.
This can be removed when switching to Python 3, as 'utf-8' is the
default there.
Necessary for merging #7422 due to the ฿ in ฿tcDrak.
This commit is contained in:
Wladimir J. van der Laan 2016-01-27 11:39:58 +01:00 committed by MarcoFalke
parent 7d99dee286
commit ee6dee4a2a

View File

@ -147,14 +147,14 @@ def main():
else: else:
firstline = 'Merge #%s' % (pull,) firstline = 'Merge #%s' % (pull,)
message = firstline + '\n\n' message = firstline + '\n\n'
message += subprocess.check_output([GIT,'log','--no-merges','--topo-order','--pretty=format:%h %s (%an)',base_branch+'..'+head_branch]) message += subprocess.check_output([GIT,'log','--no-merges','--topo-order','--pretty=format:%h %s (%an)',base_branch+'..'+head_branch]).decode('utf-8')
try: try:
subprocess.check_call([GIT,'merge','-q','--commit','--no-edit','--no-ff','-m',message,head_branch]) subprocess.check_call([GIT,'merge','-q','--commit','--no-edit','--no-ff','-m',message.encode('utf-8'),head_branch])
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
print("ERROR: Cannot be merged cleanly.",file=stderr) print("ERROR: Cannot be merged cleanly.",file=stderr)
subprocess.check_call([GIT,'merge','--abort']) subprocess.check_call([GIT,'merge','--abort'])
exit(4) exit(4)
logmsg = subprocess.check_output([GIT,'log','--pretty=format:%s','-n','1']) logmsg = subprocess.check_output([GIT,'log','--pretty=format:%s','-n','1']).decode('utf-8')
if logmsg.rstrip() != firstline.rstrip(): if logmsg.rstrip() != firstline.rstrip():
print("ERROR: Creating merge failed (already merged?).",file=stderr) print("ERROR: Creating merge failed (already merged?).",file=stderr)
exit(4) exit(4)