X-Git-Url: http://git.ieval.ro/?p=fdkaac.git;a=blobdiff_plain;f=git2changelog.py;h=2b2ba605fb713aea812dc059c81cdae0b2845ce2;hp=91be8c77d04504fa803a1fb702459a60a35e8b76;hb=a854b113ae1b8d195b040530ba3c15830c03666b;hpb=2f960ef8fd00a3bf748e0b16b61acba20b3af455 diff --git a/git2changelog.py b/git2changelog.py index 91be8c7..2b2ba60 100755 --- a/git2changelog.py +++ b/git2changelog.py @@ -15,15 +15,19 @@ GITLOG_CMD = ['git','log','--date=short','--format={0}'.format(GITLOG_FMT)] Commit = namedtuple('Commit', 'commit author date subject ref') def parse_gitlog(stream): - re_decode_tag = re.compile(r'(?<=\()([^,)]+)') + re_decode_ref = re.compile(r'(?<=\()([^,)]+)') + re_strip_tag = re.compile(r'^tag: ') commit = dict() for line in stream: fields = line.decode('utf-8').rstrip('\r\n').split(' ', 1) if len(fields) == 2: key, value = fields if key == 'ref': - m = re_decode_tag.search(value) - value = ' [{0}]'.format(m.group()) if m else '' + m = re_decode_ref.search(value) + if m: + value = ' [{0}]'.format(re_strip_tag.sub('', m.group())) + else: + value = '' commit[key] = value elif commit: yield Commit(**commit) @@ -35,6 +39,6 @@ with Popen(GITLOG_CMD, shell=False, stdout=PIPE).stdout as pipe: commits = parse_gitlog(pipe) commits_by_date_author = groupby(commits, key=lambda x: (x.date, x.author)) for (date, author), commits in commits_by_date_author: - output('{0} {1}\n\n'.format(date, author)) + output(u'{0} {1}\n\n'.format(date, author).encode('utf-8')) for c in commits: - output(' * {0}{1}\n\n'.format(c.subject, c.ref)) + output(u' * {0}{1}\n\n'.format(c.subject, c.ref).encode('utf-8'))