]>
iEval git - fdkaac.git/blob - git2changelog.py
3 # Copyright (C) 2013 nu774
4 # For conditions of distribution and use, see copyright notice in COPYING
8 from subprocess
import Popen
, PIPE
9 from itertools
import groupby
10 from collections
import namedtuple
12 GITLOG_FMT
= 'commit %H%nauthor %cn <%ae>%ndate %ad%nsubject %s%nref %d%n%n'
13 GITLOG_CMD
= ['git','log','--date=short','--format={0}'.format(GITLOG_FMT
)]
15 Commit
= namedtuple('Commit', 'commit author date subject ref')
17 def parse_gitlog(stream
):
18 re_decode_ref
= re
.compile(r
'(?<=\()([^,)]+)')
19 re_strip_tag
= re
.compile(r
'^tag: ')
22 fields
= line
.decode('utf-8').rstrip('\r\n').split(' ', 1)
26 m
= re_decode_ref
.search(value
)
28 value
= ' [{0}]'.format(re_strip_tag
.sub('', m
.group()))
33 yield Commit(**commit
)
36 output
=sys
.stdout
.write
38 with
Popen(GITLOG_CMD
, shell
=False, stdout
=PIPE
).stdout
as pipe
:
39 commits
= parse_gitlog(pipe
)
40 commits_by_date_author
= groupby(commits
, key
=lambda x
: (x
.date
, x
.author
))
41 for (date
, author
), commits
in commits_by_date_author
:
42 output(u
'{0} {1}\n\n'.format(date
, author
).encode('utf-8'))
44 output(u
' * {0}{1}\n\n'.format(c
.subject
, c
.ref
).encode('utf-8'))
This page took 0.049102 seconds and 4 git commands to generate.