@@ -0,0 +1,2470 @@
+#!/usr/bin/env python%0A%0Aimport argparse%0A%0Afrom pygerrit2 import GerritRestAPI, GerritReview, HTTPDigestAuthFromNetrc%0A%0AGERRIT_URL = 'https://gerrit.suse.provo.cloud/'%0A%0A%0Adef gerrit_review(change_no, patch=None, label=None, vote=1, message=''):%0A    auth = HTTPDigestAuthFromNetrc(url=GERRIT_URL)%0A    rest = GerritRestAPI(url=GERRIT_URL, auth=auth, verify=False)%0A    change = rest.get(%22/changes/?q=%7B%7D%22.format(change_no))%5B0%5D%0A    print(%22Posting %7B%7D: %7B%7D review for change: '%7B%7D'%22.format(label, vote,%0A                                                          change%5B'subject'%5D))%0A    if not patch:%0A        current_rev = rest.get(%22/changes/?q=%7B%7D&o=CURRENT_REVISION%22.format(%0A            change%5B'_number'%5D))%0A        patch = current_rev%5B0%5D%5B'revisions'%5D.values()%5B0%5D%5B'_number'%5D%0A    rev = GerritReview()%0A    rev.set_message(message)%0A    if label:%0A        rev.add_labels(%7Blabel: vote%7D)%0A%0A    rest.review(change%5B'_number'%5D, patch, rev)%0A%0A%0Adef main():%0A    parser = argparse.ArgumentParser(%0A        description='Post a Gerrit review')%0A    parser.add_argument('change',%0A                        help='the Gerrit change number (e.g. 1234)')%0A    parser.add_argument('--patch',%0A                        default='0',%0A                        help='the Gerrit patch number (e.g. 3). If not '%0A                             'supplied, the latest patch will be used')%0A    parser.add_argument('--label',%0A                        default=None,%0A                        choices=%5B'Code-Review', 'Verified', 'Workflow'%5D,%0A                        help='a label to use for voting')%0A    parser.add_argument('--vote',%0A                        default='1',%0A                        choices=%5B'-2', '-1', '0', '+1', '+2'%5D,%0A                        help='the vote value given for the label')%0A    parser.add_argument('--message',%0A                        default='',%0A                        help='string message to be posted with the review')%0A    parser.add_argument('--message-file',%0A                        default=None,%0A                        help='append file contents to the message to be '%0A                             'posted with the review')%0A%0A    args = parser.parse_args()%0A%0A    message = args.message%0A    if args.message_file:%0A        with open(args.message_file) as msg_file:%0A            message += msg_file.read()%0A%0A    gerrit_review(int(args.change),%0A                  int(args.patch),%0A                  args.label,%0A                  int(args.vote),%0A                  message)%0A%0A%0Aif __name__ == '__main__':%0A    main()%0A

gerrit review script