Fix non-ascii merge commit messages in python2

This commit is contained in:
Anthony Sottile
2017-05-10 12:49:39 -07:00
parent e3b14c35f7
commit 964948b33d
3 changed files with 18 additions and 5 deletions

View File

@@ -48,10 +48,10 @@ def is_in_merge_conflict():
def parse_merge_msg_for_conflicts(merge_msg):
# Conflicted files start with tabs
return [
line.lstrip('#').strip()
line.lstrip(b'#').strip().decode('UTF-8')
for line in merge_msg.splitlines()
# '#\t' for git 2.4.1
if line.startswith(('\t', '#\t'))
if line.startswith((b'\t', b'#\t'))
]
@@ -60,7 +60,7 @@ def get_conflicted_files():
logger.info('Checking merge-conflict files only.')
# Need to get the conflicted files from the MERGE_MSG because they could
# have resolved the conflict by choosing one side or the other
merge_msg = open(os.path.join(get_git_dir('.'), 'MERGE_MSG')).read()
merge_msg = open(os.path.join(get_git_dir('.'), 'MERGE_MSG'), 'rb').read()
merge_conflict_filenames = parse_merge_msg_for_conflicts(merge_msg)
# This will get the rest of the changes made after the merge.