diff --git a/.reviewboardrc b/.reviewboardrc new file mode 100644 index 0000000..5e8d670 --- /dev/null +++ b/.reviewboardrc @@ -0,0 +1,3 @@ +REPOSITORY = 'git://git.apache.org/kafka.git' +TARGET_GROUPS = 'kafka' +GUESS_FIELDS = True diff --git a/kafka-patch-review.py b/kafka-patch-review.py new file mode 100644 index 0000000..7b551b6 --- /dev/null +++ b/kafka-patch-review.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python + +import argparse +import sys +import os + +def main(): + ''' main(), shut up, pylint ''' + popt = argparse.ArgumentParser(description='Kafka patch review tool') + popt.add_argument('-b', '--branch', action='store', dest='branch', required=True, help='Tracking branch to create diff against') + popt.add_argument('-j', '--jira', action='store', dest='jira', required=True, help='JIRA corresponding to the reviewboard') + popt.add_argument('-s', '--summary', action='store', dest='summary', required=False, help='Summary for the reviewboard') + popt.add_argument('-d', '--description', action='store', dest='description', required=False, help='Description for reviewboard') + popt.add_argument('-r', '--rb', action='store', dest='reviewboard', required=False, help='Review board that needs to be updated') + popt.add_argument('-v', '--version', action='store', dest='version', required=False, help='Version of the patch') + popt.add_argument('-db', '--debug', action='store_true', required=False, help='Enable debug mode') + opt = popt.parse_args() + + jira_home=os.getenv('JIRA_CMDLINE_HOME') + if jira_home is None: + print 'ERROR: Set the JIRA_CMDLINE_HOME to the location of the jira command line tool package' + sys.exit(1) + else: + jira_home=jira_home.rstrip('/') + if opt.debug: + print 'Jira Home=',jira_home + + version="v1" + if opt.version: + version=opt.version + patch_file=opt.jira + "-" + version + ".patch" + + git_command="git diff " + opt.branch + " > " + patch_file + if opt.debug: + print git_command + p=os.popen(git_command) + + jira_path=jira_home + "/jira.sh" + jira_command=jira_path + ' --action addAttachment --issue ' + opt.jira + ' --file ' + patch_file + print 'Creating diff against', opt.branch, 'and uploading patch to JIRA',opt.jira + if opt.debug: + print jira_command + p=os.popen(jira_command) + + if not opt.reviewboard: + print 'Creating reviewboard' + else: + print 'Updating reviewboard',opt.reviewboard + rb_command="post-review --publish --tracking-branch " + opt.branch + " --target-groups=kafka --bugs-closed=" + opt.jira + if opt.summary: + rb_command=rb_command + " --summary \"" + opt.summary + "\"" + if opt.description: + rb_command=rb_command + " --description \"" + opt.description + "\"" + if opt.reviewboard: + rb_command=rb_command + " -r " + opt.reviewboard + if opt.debug: + print rb_command + p=os.popen(rb_command) + +if __name__ == '__main__': + sys.exit(main()) +