]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ptl-tool: print bzs/tickets cited in commit msgs 18547/head
authorPatrick Donnelly <pdonnell@redhat.com>
Wed, 25 Oct 2017 22:54:14 +0000 (15:54 -0700)
committerPatrick Donnelly <pdonnell@redhat.com>
Tue, 31 Oct 2017 03:11:35 +0000 (20:11 -0700)
This makes it easier to update issues after a merge.

Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
src/script/ptl-tool.py

index c5875de008783ce317bf81e2956b3c0582b4116c..097deebc1b55b99a231f1d85882d4db40e1ffee4 100755 (executable)
@@ -113,6 +113,9 @@ with open(".githubmap") as f:
         m = patt.match(line)
         CONTRIBUTORS[m.group(1)] = m.group(2)
 
+BZ_MATCH = re.compile("(.*https?://bugzilla.redhat.com/.*)")
+TRACKER_MATCH = re.compile("(.*https?://tracker.ceph.com/.*)")
+
 def build_branch(args):
     base = args.base
     branch = args.branch
@@ -182,10 +185,21 @@ def build_branch(args):
             sys.exit(1)
         tip = fi[0].ref.commit
 
+        pr_req = requests.get("https://api.github.com/repos/ceph/ceph/pulls/{pr}".format(pr=pr), auth=(USER, PASSWORD))
+        if pr_req.status_code != 200:
+            log.error("PR '{pr}' not found: {c}".format(pr=pr,c=pr_req))
+            sys.exit(1)
+
         message = "Merge PR #%d into %s\n\n* %s:\n" % (pr, args.merge_branch_name, remote_ref)
 
         for commit in G.iter_commits(rev="HEAD.."+str(tip)):
             message = message + ("\t%s\n" % commit.message.split('\n', 1)[0])
+            # Get tracker issues / bzs cited so the PTL can do updates
+            short = commit.hexsha[:8]
+            for m in BZ_MATCH.finditer(commit.message):
+                log.info("[ {sha1} ] BZ cited: {cite}".format(sha1=short, cite=m.group(1)))
+            for m in TRACKER_MATCH.finditer(commit.message):
+                log.info("[ {sha1} ] Ceph tracker cited: {cite}".format(sha1=short, cite=m.group(1)))
 
         message = message + "\n"
 
@@ -205,7 +219,13 @@ def build_branch(args):
             sys.exit(1)
 
         indications = set()
-        for comment in comments.json()+review_comments.json():
+        for comment in [pr_req.json()]+comments.json()+reviews.json()+review_comments.json():
+            body = comment["body"]
+            url = comment["html_url"]
+            for m in BZ_MATCH.finditer(body):
+                log.info("[ {url} ] BZ cited: {cite}".format(url=url, cite=m.group(1)))
+            for m in TRACKER_MATCH.finditer(body):
+                log.info("[ {url} ] Ceph tracker cited: {cite}".format(url=url, cite=m.group(1)))
             for indication in INDICATIONS:
                 for cap in indication.findall(comment["body"]):
                     indications.add(cap)