]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tools: src/script/ceph-release-notes normalization 5240/head
authorLoic Dachary <ldachary@redhat.com>
Tue, 14 Jul 2015 13:59:38 +0000 (15:59 +0200)
committerLoic Dachary <ldachary@redhat.com>
Tue, 14 Jul 2015 14:21:04 +0000 (16:21 +0200)
Issue an error if for the title does not start with a known prefix.
Issue an error if no issue is associated to a pull request.

Group the pull requests fixing the same issue together.

Add link to the issue and the pull request.

Signed-off-by: Loic Dachary <loic@dachary.org>
src/script/ceph-release-notes

index 84fdfe4a50bfbccb2853ee162440b1e34eb7a512..6f96457be3afc18ae6efe1a44d5c21e8c6b594dd 100755 (executable)
@@ -20,10 +20,11 @@ ceph_release_notes -r tags/v0.87..giant /path/to/ceph/repo
 """
 
 from __future__ import print_function
-import re
-import os
 import argparse
 import github
+import os
+import re
+import sys
 
 from git import Repo
 
@@ -36,12 +37,14 @@ signed_off_re = re.compile("Signed-off-by: (.+) <")
 
 def make_release_notes(gh, repo, ref):
 
+    issue2prs = {}
+
     for commit in repo.iter_commits(ref):
         merge = merge_re.match(commit.summary)
         if merge:
-            pr = {}
             issue = ''
-            pr = gh.repos("ceph")("ceph").pulls(merge.group(1)).get()
+            number = merge.group(1)
+            pr = gh.repos("ceph")("ceph").pulls(number).get()
             # We are not handling multiple issues here yet
             if pr['body']:
                 fixes = fixes_re.findall(pr['body'])
@@ -51,17 +54,28 @@ def make_release_notes(gh, repo, ref):
                 elif fixes:
                     issue = ','.join(fixes)
 
+            if not issue:
+                print ("ERROR: http://github.com/ceph/ceph/pull/" + str(number) + " has no associated issue")
+                continue    
+
             title = pr['title']
 
+            title_re = '^(common|mon|osd|fs|librbd|rbd|fs|mds|objecter|rgw|build/ops|tests|tools|doc|crush|librados):'
+            if not re.match(title_re, title):
+                print ("ERROR: http://github.com/ceph/ceph/pull/" + str(number) + " title " + title + " does not match " + title_re)
             # Big assumption, do a sanity check in the end, we are
             # getting the author of final merge commit
             author = commit.parents[-1].author.name
-            if issue:
-                print ("{0} (#{1}, {2})".format(title, issue, author))
-            elif author:
-                print ("{0} ({1})".format(title, author))
-            else:
-                print (title)
+            issue2prs.setdefault(issue, []).append((author, title, number))
+            sys.stdout.write('.')
+
+    print (" done collecting merges.")
+
+    for (issue, prs) in issue2prs.iteritems():
+        if len(prs) > 1:
+            print (">>>>>>> " + str(len(prs)) + " pr for issue " + issue)
+        for (author, title, number) in prs:
+            print ("* {title} (`issue#{issue} <http://tracker.ceph.com/issues/{issue}>`_, `pr#{number} <http://github.com/ceph/ceph/pull/{number}>`_, {author})".format(title=title, issue=issue, author=author, number=number))
 
 
 if __name__ == "__main__":