]> git.0d.be Git - empathy.git/blobdiff - release.py
remove released flag
[empathy.git] / release.py
index bbebe031d69ba63dd1ae7de2661fb46f3f8babf5..160650ed1c3992a944ac4b274d9674d57363fef2 100755 (executable)
@@ -5,10 +5,11 @@ import re
 import urllib
 import csv
 import datetime
+import time
 from string import Template
 from optparse import OptionParser
 
-username = 'xclaesse'
+last_tag_pattern = 'EMPATHY_3_9*'
 upload_server = 'master.gnome.org'
 template = '''\
 $name $version is now available for download from:
@@ -66,6 +67,10 @@ 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_pattern))
+               tags = tags_str.splitlines()
+               self.last_tag = tags[len(tags)-1]
+
        def exec_cmd(self,cmd):
                return os.popen(cmd).read()
 
@@ -83,12 +88,9 @@ class Project:
        def get_md5sums(self):
                md5sums = ''
 
-               cmd = 'md5sum %s-%s.tar.gz' % (self.package_name.lower(), self.package_version)
+               cmd = 'md5sum %s-%s.tar.xz' % (self.package_name.lower(), self.package_version)
                md5sums += self.exec_cmd(cmd)
 
-               cmd = 'md5sum %s-%s.tar.bz2' % (self.package_name.lower(), self.package_version)
-               md5sums += self.exec_cmd(cmd).strip()
-
                return md5sums
 
        def get_bugzilla_info(self):
@@ -104,10 +106,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)
@@ -128,51 +130,57 @@ class Project:
                t = Template(template)
                return t.substitute(locals())
        
-       def get_last_tag(self):
-               tags_str = self.exec_cmd('git tag')
-               tags = tags_str.splitlines()
-
-               return tags[len(tags)-1]
-
-       def parse_commit(self, ref, author, date, message):
-               p1 = message.rfind('(')
-               p2 = message.rfind (')')
-               if len(message) - p2 <= 2 and \
-                  message[p1+1:].find('#') == -1:
-                       author = message[p1+1:p2]
-                       message = message[:p1]
-
-               msg = message.lower()
-               if msg.find('translation') != -1 and \
-                  (msg.find('added') != -1 or \
-                   msg.find('updated') != -1):
-                       self.translations += ' - ' + message + ' (' + author + ').\n' 
-               elif message.find('#') != -1:
-                       p1 = message.find('#')
-                       while p1 != -1:
-                               bug = Bug()
-                               p2 = p1 + 1
-                               while p2 < len (message) and \
-                                     message[p2].isdigit():
-                                       p2 = p2 + 1
-                               bug.number = message[p1+1:p2]
-                               bug.author = author
-                               self.bug_commits.append(bug)
-                               p1 = message.find('#', p2)
-               else:
-                       self.commits += ' - ' + message + ' (' + author + ').\n'
-
-       def query_bug_commits(self):
-               bugs = ''
-               for bug in self.bug_commits:
-                       bugs += bug.number + ','
-
-               # Bugzilla query to use
-               query = 'http://bugzilla.gnome.org/buglist.cgi?ctype=csv' \
-                       '&bug_status=RESOLVED,CLOSED,VERIFIED' \
-                       '&resolution=FIXED' \
-                       '&bug_id=' + bugs.replace(',', '%2c')
-
+       def get_translations(self, cmd, format):
+               translations = ''
+               files_str = self.exec_cmd(cmd)
+               files = files_str.splitlines()
+               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
+
+                       authors = ''
+                       for line in commit_str.splitlines():
+                               if line.startswith('Author:'):
+                                       p1 = line.find(' ')
+                                       p2 = line.find('<')
+                                       author = line[p1:p2].strip()
+
+                                       if authors.find(author) != -1:
+                                               continue
+                                       if authors != '':
+                                               authors += ", "
+                                       authors += author
+
+                       translations += format % (lang, authors)
+               return translations
+
+       def get_bug_author(self, bug_number):
+               cmd = 'git log %s.. | grep -B 20 -E \
+                     "(bug %s|#%s)|bugzilla.gnome.org/show_bug.cgi\?id=%s"' \
+                     ' | tac | grep ^Author: | head -1' \
+                     % (self.last_tag, bug_number, 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' % (last_tag_date)
                f = urllib.urlopen(query)
                s = f.read()
                f.close()
@@ -191,72 +199,35 @@ class Project:
                                col_description = i
                        i = i + 1
 
+               bugs = ''
                for row in reader:
                        bug_number = row[col_bug_id]
                        description = row[col_description]
-
-                       for bug in self.bug_commits:
-                               if bug.number == bug_number:
-                                       self.bugs += ' - Fixed #%s, %s (%s)\n' % (bug.number, description, bug.author)
-                                       break
-
-       def get_commits(self):
-               self.commits = ''
-               self.translations = ''
-               self.bugs = ''
-               self.bug_commits = []
-               last_tag = self.get_last_tag()
-               ref = None
-
-               changes = self.exec_cmd ("git log " + last_tag + "..")
-               for line in changes.splitlines(1):
-                       if line.startswith('commit'):
-                               if ref != None:
-                                       self.parse_commit (ref, author, date, message)
-                               p1 = line.find(' ')
-                               ref = line[p1:].strip()
-                               author = ''
-                               date = ''
-                               message = ''
-                       elif line.startswith('Author:'):
-                               p1 = line.find(' ')
-                               p2 = line.find('<')
-                               author = line[p1:p2].strip()
-                       elif line.startswith('Date:'):
-                               p1 = line.find(' ')
-                               date = line[p1:].strip()
-                       elif line.startswith('    git-svn-id:'):
-                               continue
-                       elif line.startswith('    Signed-off-by:'):
-                               continue
-                       elif line.startswith('    From:'):
-                               continue
-                       elif line.startswith('Merge:'):
-                               continue
-                       else:
-                               msg = line.strip()
-                               if msg == '':
-                                       continue
-                               if message != '':
-                                       message += '\n'
-                               message += msg
-
-               self.query_bug_commits ()
-
-       def make_tag(self):
-               new_tag = self.package_name.upper() + '_' +\
-                         self.package_version.replace('.', '_')
-
-               url1 = self.exec_cmd('git config svn-remote.svn.url').strip()
-               url2 = url1[:url1.rfind('/')] + '/tags/' + new_tag
-               self.exec_cmd('svn copy %s %s -m "Tagged for release %s."' % (url1, url2, self.package_version))
-
-               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_commits()
-               news = 'NEW in '+ self.package_version + '\n==============\n' 
-               news += self.commits + '\nBugs fixed:\n' + self.bugs + '\nTranslations:\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
 
@@ -270,8 +241,22 @@ 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):
-               tarball = '%s-%s.tar.gz' % (self.package_name.lower(), self.package_version)
+               username = self._get_username()
+               tarball = '%s-%s.tar.xz' % (self.package_name.lower(), self.package_version)
 
                cmd = 'scp %s %s@%s:' % (tarball, username, upload_server)
                self.exec_cmd(cmd)
@@ -281,6 +266,7 @@ class Project:
 
        def send_email(self):
                notes = self.get_release_notes()
+                print notes
                cmd = 'xdg-email ' \
                      ' --cc telepathy@lists.freedesktop.org' \
                      ' --subject "ANNOUNCE: Empathy %s"' \