Skip to content

Commit

Permalink
KAFKA-1442 RBTools post-review is deprecated; reviewed by Neha Narkhede
Browse files Browse the repository at this point in the history
  • Loading branch information
Sriharsha Chintalapani authored and nehanarkhede committed May 8, 2014
1 parent 754dacb commit 1d35cce
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions kafka-patch-review.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

import argparse
import sys
import os
import os
import time
import datetime
import tempfile
import commands
from jira.client import JIRA

def get_jira():
Expand All @@ -17,7 +18,11 @@ def get_jira():
home=home.rstrip('/')
jira_config = dict(line.strip().split('=') for line in open(home + '/jira.ini'))
jira = JIRA(options,basic_auth=(jira_config['user'], jira_config['password']))
return jira
return jira

def cmd_exists(cmd):
status, result = commands.getstatusoutput(cmd)
return status

def main():
''' main(), shut up, pylint '''
Expand All @@ -31,6 +36,15 @@ def main():
popt.add_argument('-db', '--debug', action='store_true', required=False, help='Enable debug mode')
opt = popt.parse_args()

post_review_tool = None
if (cmd_exists("post-review") == 0):
post_review_tool = "post-review"
elif (cmd_exists("rbt") == 0):
post_review_tool = "rbt post"
else:
print "please install RBTools"
sys.exit(1)

patch_file=tempfile.gettempdir() + "/" + opt.jira + ".patch"
if opt.reviewboard:
ts = time.time()
Expand Down Expand Up @@ -62,9 +76,9 @@ def main():
p=os.popen(git_remote_update)
p.close()

rb_command="post-review --publish --tracking-branch " + opt.branch + " --target-groups=kafka --bugs-closed=" + opt.jira
rb_command= post_review_tool + " --publish --tracking-branch " + opt.branch + " --target-groups=kafka --bugs-closed=" + opt.jira
if opt.debug:
rb_command=rb_command + " --debug"
rb_command=rb_command + " --debug"
summary="Patch for " + opt.jira
if opt.summary:
summary=opt.summary
Expand Down Expand Up @@ -92,9 +106,9 @@ def main():
p.close()
sys.exit(1)
p.close()
if opt.debug:
if opt.debug:
print 'rb url=',rb_url

git_command="git diff " + opt.branch + " > " + patch_file
if opt.debug:
print git_command
Expand All @@ -108,16 +122,15 @@ def main():
jira.add_attachment(issue,attachment)
attachment.close()

comment="Created reviewboard "
comment="Created reviewboard "
if not opt.reviewboard:
print 'Created a new reviewboard ',rb_url,
print 'Created a new reviewboard',rb_url,
else:
print 'Updated reviewboard'
print 'Updated reviewboard',rb_url
comment="Updated reviewboard "

comment = comment + rb_url + ' against branch ' + opt.branch
comment = comment + rb_url + ' against branch ' + opt.branch
jira.add_comment(opt.jira, comment)

if __name__ == '__main__':
sys.exit(main())

0 comments on commit 1d35cce

Please sign in to comment.