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_tag
= re
.compile(r
'(?<=\()([^,)]+)')
21 fields
= line
.decode('utf-8').rstrip('\r\n').split(' ', 1)
25 m
= re_decode_tag
.search(value
)
26 value
= ' [{0}]'.format(m
.group()) if m
else ''
29 yield Commit(**commit
)
32 output
=sys
.stdout
.write
34 with
Popen(GITLOG_CMD
, shell
=False, stdout
=PIPE
).stdout
as pipe
:
35 commits
= parse_gitlog(pipe
)
36 commits_by_date_author
= groupby(commits
, key
=lambda x
: (x
.date
, x
.author
))
37 for (date
, author
), commits
in commits_by_date_author
:
38 output('{0} {1}\n\n'.format(date
, author
))
40 output(' * {0}{1}\n\n'.format(c
.subject
, c
.ref
))
This page took 0.02225 seconds and 4 git commands to generate.