py3: update changelog generation to use strings
gitea/eobuilder/pipeline/head Build started... Details

This commit is contained in:
Frédéric Péters 2020-04-18 14:54:56 +02:00
parent 1e9c8dba10
commit 5be937b645
1 changed files with 5 additions and 2 deletions

View File

@ -1,3 +1,4 @@
import codecs
import datetime
import textwrap
import os
@ -66,7 +67,9 @@ def changelog_from_git(project, version_suffix, path,
if i == n-1:
logs = [commit] + list(commit.iter_parents())
else:
reflog = '%s..%s' % (versions[i+1][1].binsha.encode('hex'), commit.binsha.encode('hex'))
def encode_hex(value):
return codecs.encode(value, 'hex').decode('ascii')
reflog = '%s..%s' % (encode_hex(versions[i+1][1].binsha), encode_hex(commit.binsha))
logs = list(Commit.iter_items(repo, reflog))
if not logs:
continue
@ -87,7 +90,7 @@ def changelog_from_git(project, version_suffix, path,
t = '(%s) %s' % (l.hexsha[:6], e)
lines = textwrap.wrap(t, 80)
for prefix, suffix in zip([' * '] + [' ']*(len(lines)-1), lines):
yield (prefix + suffix).encode('utf-8')
yield (prefix + suffix)
paris = pytz.timezone('Europe/Paris')
date = datetime.datetime.fromtimestamp(logs[0].committed_date + logs[0].committer_tz_offset).replace(
tzinfo=pytz.UTC).astimezone(paris).strftime('%a, %d %b %Y %H:%M:%S %z')