X-Git-Url: https://git.0d.be/?p=empathy.git;a=blobdiff_plain;f=release.py;h=00ca67ead5aab437ccd62201afdc581d89475a00;hp=4d3644cb8b7f27394fd47f59b8d108ac1d958b01;hb=6c5839c976407292715daf22cdddf6aca469fa75;hpb=c6321f543d21f1e0074281178ec2011c6294b1e7 diff --git a/release.py b/release.py index 4d3644cb..00ca67ea 100755 --- a/release.py +++ b/release.py @@ -5,11 +5,11 @@ import re import urllib import csv import datetime +import time from string import Template from optparse import OptionParser -last_tag_patern = 'EMPATHY_2_26*' -username = 'xclaesse' +last_tag_pattern = 'EMPATHY_2_91*' upload_server = 'master.gnome.org' template = '''\ $name $version is now available for download from: @@ -67,7 +67,7 @@ class Project: version_dir = self.package_version[:second] self.package_dl_url = 'http://download.gnome.org/sources/%s/%s/' % (self.package_name.lower(), version_dir) - tags_str = self.exec_cmd('git tag -l %s' % (last_tag_patern)) + tags_str = self.exec_cmd('git tag -l %s' % (last_tag_pattern)) tags = tags_str.splitlines() self.last_tag = tags[len(tags)-1] @@ -109,10 +109,10 @@ class Project: end = s.find(s2, i + 1) description = s[start:end] - s1 = "GNOME SVN" + s1 = "homepage" i = s.find(s1) s1 = "href" - i = s.find(s1, i) + i = s.rfind(s1, 0, i) start = i + 6 s2 = '">' end = s.find(s2, start) @@ -133,12 +133,13 @@ class Project: t = Template(template) return t.substitute(locals()) - def get_translations(self): - self.translations = '' - files_str = self.exec_cmd("ls po/*.po") + def get_translations(self, cmd, format): + translations = '' + files_str = self.exec_cmd(cmd) files = files_str.splitlines() - for f in files: - lang = f[3:len(f)-3] + for line in files: + f = line[line.rfind(' '):] + lang = f[f.rfind('/')+1:f.rfind('.')] commit_str = self.exec_cmd("git log %s.. %s" % (self.last_tag, f)) if commit_str == '': continue @@ -156,13 +157,32 @@ class Project: authors += ", " authors += author - self.translations += "Updated %s Translation (%s)\n" % (lang, authors) + translations += format % (lang, authors) + return translations + + def get_bug_author(self, bug_number): + cmd = 'git log %s.. | grep -B 20 -E "(bug %s|#%s)"' \ + ' | tac | grep ^Author: | head -1' \ + % (self.last_tag, bug_number, bug_number) + line = self.exec_cmd (cmd) + p1 = line.find(" ") + p2 = line.find("<") + + return line[p1:p2].strip() def get_bugs(self): + commit_str = self.exec_cmd('git show %s' % (self.last_tag)) + for line in commit_str.splitlines(): + if line.startswith('Date:'): + time_str = line[5:line.rfind('+')].strip() + t = time.strptime(time_str) + last_tag_date = time.strftime('%Y-%m-%d', t) + break + query = 'http://bugzilla.gnome.org/buglist.cgi?' \ 'ctype=csv&product=empathy&' \ 'bug_status=RESOLVED,CLOSED,VERIFIED&resolution=FIXED&' \ - 'chfieldfrom=%s&chfieldto=Now' % ('2009-04-13') + 'chfieldfrom=%s&chfieldto=Now' % (last_tag_date) f = urllib.urlopen(query) s = f.read() f.close() @@ -181,25 +201,35 @@ class Project: col_description = i i = i + 1 - self.bugs = '' + bugs = '' for row in reader: bug_number = row[col_bug_id] description = row[col_description] - self.bugs += ' - Fixed #%s, %s\n' % (bug_number, description) - - def make_tag(self): - new_tag = self.package_name.upper() + '_' +\ - self.package_version.replace('.', '_') - self.exec_cmd('git tag -m "Tagged for release %s." %s' % ( self.package_version, new_tag)) + author = self.get_bug_author(bug_number) + bugs += ' - Fixed #%s, %s' % (bug_number, description) + if author != '': + bugs += ' (%s)' % (author) + bugs += '\n' + return bugs def generate_news(self): - self.get_translations() - self.get_bugs() - news = 'NEW in '+ self.package_version + '\n==============\n' - if self.bugs != '': - news += 'Bugs fixed:\n' + self.bugs + '\n' - if self.translations != '': - news += 'Translations:\n' + self.translations + '\n' + translations = self.get_translations("ls -l po/*.po", \ + " - Updated %s Translation (%s)\n") + help_translations = self.get_translations("ls -l help/*/*.po", \ + " - Updated %s Documentation translation (%s)\n") + bugs = self.get_bugs() + + news = 'NEW in '+ self.package_version + line = '=' * len(news) + today = datetime.date.today() + news += ' (%s)\n%s\n' % (today.strftime('%d/%m/%Y'),line) + if bugs != '': + news += 'Bugs fixed:\n' + bugs + '\n' + if translations != '': + news += 'Translations:\n' + translations + '\n' + if help_translations != '': + news += 'Documentation translations:\n' + \ + help_translations + '\n' return news @@ -213,7 +243,21 @@ class Project: self.exec_cmd('cat NEWS >> /tmp/NEWS') self.exec_cmd('mv /tmp/NEWS .') + def make_tag(self): + new_tag = self.package_name.upper() + '_' +\ + self.package_version.replace('.', '_') + self.exec_cmd('git tag -m "Tagged for release %s." %s' % ( self.package_version, new_tag)) + + def _get_username(self): + username = os.environ.get('GNOME_ACCOUNT_NAME') + if username is not None: + return username + + return os.getlogin() + + def upload_tarball(self): + username = self._get_username() tarball = '%s-%s.tar.gz' % (self.package_name.lower(), self.package_version) cmd = 'scp %s %s@%s:' % (tarball, username, upload_server)