diff options
author | Marco Pesenti Gritti <marco@localhost.localdomain> | 2008-06-28 09:35:38 (GMT) |
---|---|---|
committer | Marco Pesenti Gritti <marco@localhost.localdomain> | 2008-06-28 09:35:38 (GMT) |
commit | 612e67a1ba8692f5c0e1501e4ed23187624eba1d (patch) | |
tree | 6202e7ff28f601ee5350cffc41623ae3684ffed9 /scripts | |
parent | 56f67fe875b908197151227ff964f4dbd0b9acf0 (diff) |
Add a release report.
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/report.py | 79 |
1 files changed, 74 insertions, 5 deletions
diff --git a/scripts/report.py b/scripts/report.py index e15cc3a..3fefec0 100644 --- a/scripts/report.py +++ b/scripts/report.py @@ -3,11 +3,14 @@ import sys import urllib import csv import json +import re import smtplib +import subprocess from optparse import make_option import StringIO from jhbuild.commands import Command, register_command +import jhbuild.moduleset def _get_ticket_uri(number): return 'http://dev.laptop.org/ticket/' + number @@ -28,13 +31,73 @@ class TextWriter(object): self.out.write(headline + '\n') self.out.write('-' * len(headline) + '\n\n') - def write_tickets(self, tickets): + def write_tickets(self, tickets, compact=False): for number, summary in tickets: - self.out.write(summary + '\n') - self.out.write(_get_ticket_uri(number) + '\n\n') + if compact: + self.out.write('* #%s %s\n' % (number, summary)) + else: + self.out.write(summary + '\n') + self.out.write(_get_ticket_uri(number) + '\n\n') + +class ReleaseReport(object): + def __init__(self, config, release): + module, self._version = release.split('-') + + module_set = jhbuild.moduleset.load(config) + self._module = module_set.modules[module] + self._config = config + self._tickets = [] + + def generate(self): + cwd = os.getcwd() + os.chdir(self._module.get_srcdir(self._config)) + + p = subprocess.Popen(['git', 'tag'], stdout=subprocess.PIPE) + tags = p.stdout.read().split('\n') + tags = [ tag for tag in tags if tag.startswith('v') ] + + release_tag = 'v' + self._version + i = tags.index(release_tag) + if i > 0: + previous = tags[i - 1] + interval = previous + '..' + release_tag + else: + interval = release_tag + + p = subprocess.Popen(['git', 'log', interval, + '--pretty=format:%an|||%s'], + stdout=subprocess.PIPE) + commits = p.stdout.read().split('\n') + + tickets = [] + for row in commits: + author, subject = row.split('|||') + + match = re.search("\#([0-9]*)", subject) + if match: + tickets.append(match.group(1)) + + for n in tickets: + f = urllib.urlopen('http://dev.laptop.org/ticket/%s?format=csv' % n) + + reader = csv.DictReader(f) + row = reader.next() + + self._tickets.append([row['id'], row['summary']]) + + f.close() + + os.chdir(cwd) + + def write(self, writer): + writer.write_headline('Closed tickets') + writer.write_tickets(self._tickets, compact=True) + + def save(self): + pass class ReviewsReport(object): - def __init__(self, config): + def __init__(self, config, args): self._requested = {} self._approved = {} self._rejected = {} @@ -123,7 +186,7 @@ class cmd_report(Command): ]) def run(self, config, options, args): - report_types = [ 'reviews' ] + report_types = [ 'reviews', 'release' ] if options.type not in report_types: print 'Available reports:\n' + '\n'.join(report_types) @@ -131,6 +194,12 @@ class cmd_report(Command): if options.type == 'reviews': report = ReviewsReport(config) + elif options.type == 'release': + if args: + report = ReleaseReport(config, args[0]) + else: + print 'Please provide a module name.' + return 1 report.generate() |