Merge branch 'tube-bus-name'
[empathy.git] / release.py
index ce0ef96a9d7d4cffc0f49e1518ec0b92da56b502..60977d502a7f4a11af6ac11ecc156c31eafcc06b 100755 (executable)
@@ -129,7 +129,7 @@ class Project:
                return t.substitute(locals())
        
        def get_last_tag(self):
-               tags_str = self.exec_cmd('git-tag')
+               tags_str = self.exec_cmd('git tag')
                tags = tags_str.splitlines()
 
                return tags[len(tags)-1]
@@ -137,19 +137,24 @@ class Project:
        def parse_commit(self, ref, author, date, message):
                p1 = message.rfind('(')
                p2 = message.rfind (')')
-               if len(message) - p2 <= 2:
+               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('updated') != -1:
+               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 = message.find(' ', p1)
+                               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)
@@ -203,7 +208,7 @@ class Project:
                last_tag = self.get_last_tag()
                ref = None
 
-               changes = self.exec_cmd ("git-log " + last_tag + "..")
+               changes = self.exec_cmd ("git log " + last_tag + "..")
                for line in changes.splitlines(1):
                        if line.startswith('commit'):
                                if ref != None:
@@ -222,6 +227,10 @@ class Project:
                                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:
@@ -232,22 +241,32 @@ class Project:
                                        message += '\n'
                                message += msg
 
-               self.query_bug_commits ()
+               if len (self.bug_commits) > 0:
+                       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))
+               info = self.exec_cmd('git svn info | grep URL')
+               url1 = info[info.find(" "):].strip()
+               
+               end = url1.find("empathy")
+               end = url1.find("/", end)
+               url2 = url1[:end] + '/tags/' + new_tag
 
-               self.exec_cmd('git-tag -m "Tagged for release %s." %s' % ( self.package_version, 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))
 
        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'
+               news = 'NEW in '+ self.package_version + '\n==============\n'
+               if self.commits != '':
+                       news += self.commits + '\n'
+               if self.bugs != '':
+                       news += 'Bugs fixed:\n' + self.bugs + '\n'
+               if self.translations != '':
+                       news += 'Translations:\n' + self.translations + '\n'
 
                return news
 
@@ -270,10 +289,20 @@ class Project:
                cmd = 'ssh %s@%s install-module -u %s' % (username, upload_server, tarball)
                self.exec_cmd(cmd)
 
+       def send_email(self):
+               notes = self.get_release_notes()
+               cmd = 'xdg-email ' \
+                     ' --cc telepathy@lists.freedesktop.org' \
+                     ' --subject "ANNOUNCE: Empathy %s"' \
+                     ' --body "%s"' \
+                     ' gnome-announce-list@gnome.org' % (self.package_version,
+                                                         notes.replace('"', '\\"'))
+               self.exec_cmd(cmd)
+
        def release(self):
                self.make_tag()
                self.upload_tarball()
-               print self.get_release_notes()
+               self.send_email()
 
 if __name__ == '__main__':
        p = Project()
@@ -286,6 +315,8 @@ if __name__ == '__main__':
                dest="write_news", help="Generate and write news into the NEWS file")
        parser.add_option("-r", "--release", action="store_true",\
                dest="release", help="Release the tarball")
+       parser.add_option("-e", "--email", action="store_true",\
+               dest="email", help="Send the release announce email")
 
        (options, args) = parser.parse_args ()
        if (options.print_news):
@@ -296,4 +327,6 @@ if __name__ == '__main__':
                p.write_news ()
        if (options.release):
                p.release ()
+       if (options.email):
+               p.send_email ()