#!/usr/bin/python
#
# git-changelog - Output a rpm changelog
#
# Copyright (C) 2009-2010 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see .
#
# Author: David Cantrell
# Author: Brian C. Lane
import os
import re
import subprocess
import sys
import textwrap
from optparse import OptionParser
class ChangeLog:
def __init__(self, name, version):
self.name = name
self.version = version
self.ignore = None
def _getCommitDetail(self, commit, field):
proc = subprocess.Popen(['git', 'log', '-1',
"--pretty=format:%s" % field, commit],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE).communicate()
ret = proc[0].strip('\n').split('\n')
if len(ret) == 1 and ret[0].find('@') != -1:
ret = ret[0].split('@')[0]
elif len(ret) == 1:
ret = ret[0]
else:
ret = filter(lambda x: x != '', ret)
return ret
def getLog(self):
if not self.name:
range = "%s.." % (self.version)
else:
range = "%s-%s.." % (self.name, self.version)
proc = subprocess.Popen(['git', 'log', '--pretty=oneline', range],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE).communicate()
lines = filter(lambda x: x.find('l10n: ') != 41 and \
x.find('Merge commit') != 41 and \
x.find('Merge branch') != 41,
proc[0].strip('\n').split('\n'))
if self.ignore and self.ignore != '':
for commit in self.ignore.split(','):
lines = filter(lambda x: not x.startswith(commit), lines)
log = []
for line in lines:
fields = line.split(' ')
commit = fields[0]
summary = self._getCommitDetail(commit, "%s")
long = self._getCommitDetail(commit, "%b")
author = self._getCommitDetail(commit, "%aE")
log.append(("%s (%s)" % (summary.strip(), author)))
return log
def formatLog(self):
s = ""
for msg in self.getLog():
sublines = textwrap.wrap(msg, 77)
s = s + "- %s\n" % sublines[0]
if len(sublines) > 1:
for subline in sublines[1:]:
s = s + " %s\n" % subline
return s
def main():
parser = OptionParser()
parser.add_option("-n", "--name", dest="name",
help="Name of package used in tags")
parser.add_option("-v", "--version", dest="version",
help="Last version, changelog is commits after this tag")
(options, args) = parser.parse_args()
cl = ChangeLog(options.name, options.version)
print cl.formatLog()
if __name__ == "__main__":
main()
6rpȄNl+J8K̈́q9rIps_ɂo@Τ2E5XiEjd̩]5NL
1[JK
5p3p(O}?\*rTʬb 2I\IPk,ï|R'!9ʸviFm;Ӂk#z^
,/ɸ=F'pAlPa|jG.
%rؐNa`:ڗkbdg75OBᠭQxU}>vE_qm{p܆btG:5 q{}lw /=rQbOUDuQ{eE`25^T @P*j%.YXvR@Ƒsӎ=߈SOZDtilkMX#6 "Zλd=x#٢QY/B%cjݕG>qt(
зPZZ jEP}S%z=P(;z-ϊMu|;{N
ȃYT+<F l,VznJEl86PzE*(%B>^/Ièm79H43}5?;f-j4\X4㬎j҉Q"ʬj;ޓY$y-WAͦP&R/pehԮ'!81L5*Mv˹".Ed4Hd\qwh6`S=q_BO"3K9zh%qvfU&hÇm6Ory{2ﺰ&bE!zfqcZ&ǮmZ!3&Ƈv̐mz?@Ẵ}MϿy@=UaDKY*'\ϫf49wO{=#d}]"SD:#6("oݙȐ:܌`5\'NfbO%Xiފi.=~*D
7zQ"~=l ;Blv\{ޖ1\ԨP~}&I%`8O.ޯD y"
GSOĴ˿}W^y:E/Vd&qV.}VK}!r^ީϒ2ʛ]8,
v?bQXei{iTY8lnFE3OuUi| u1Jۦ7A Nv` DV+#80؟Mx0w1BRƿuaъ]:M"<)ӕF46X>c_8B;C<(lԵ;9#HPe@kڙD(EjiQiFp7n뫫*1ۯ$9Sr>gurDOh}Nd~
V0jaW-mg!\y/0df:.1J>3bj^?x۱ooӮ-\eZ*3AŊu!ԉVR]4~FruFh:6x4m8q$Շ9KwXǠaf{t$!LAM ΫFwej!HUUuݼYJ.48xSjlƏP$ak^̇w d$$w!
I]op3$l+1->DبC#\p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