def review_minusone(ctx, gerrit_change_id, project, username, message, interactive): """ Prefer the code is not submitted. """ slab_logger.info('Applying -1 to gerrit change %s' % gerrit_change_id) try: if not username: username = ctx.get_username() if not project: project = helper_utils.get_current_service(ctx.path)[1] if interactive: project = click.prompt( "Project Name", default=helper_utils.get_current_service(ctx.path)[1]) else: slab_logger.log(25, "current project is " + project) if interactive and not message: message = click.prompt("Message", default=message) gfn = gerrit_functions.GerritFns(username, project, ctx) gfn.change_review(gerrit_change_id, -1, 0, message) except Exception as ex: slab_logger.error(str(ex))
def review_out(ctx, project, username, detail, interactive): """ Searches through Gerrit's API for outgoing reviews for your username. """ slab_logger.info('Searching gerrit for outgoing reviews') try: if not username: username = ctx.get_username() if not project: project = helper_utils.get_current_service(ctx.path)[1] if interactive: project = click.prompt( "Project Name", default=helper_utils.get_current_service(ctx.path)[1]) else: slab_logger.log(25, "current project is " + project) gfn = gerrit_functions.GerritFns(username, project, ctx) if detail: gfn.print_gerrit(pformat="detail", number=None, owner=username, reviewer="", status="open") else: gfn.print_gerrit(pformat="summary", number=None, owner=username, reviewer="", status="open") except Exception as ex: slab_logger.error(str(ex))
def review_abandon(ctx, gerrit_change_id, project, username, message, interactive): """ Abandon a gerrit change set. """ slab_logger.info('Abadoning change %s' % gerrit_change_id) try: if not username: username = ctx.get_username() if not project: project = helper_utils.get_current_service(ctx.path)[1] if interactive: project = click.prompt( "Project Name", default=helper_utils.get_current_service(ctx.path)[1]) else: slab_logger.log(25, "current project is " + project) if interactive and not message: message = click.prompt("Message", default=message) gfn = gerrit_functions.GerritFns(username, project, ctx) gfn.code_state(gerrit_change_id, "abandon", message) except Exception as ex: slab_logger.error(str(ex))
def review_plusone(ctx, gerrit_change_id, project, username, message, interactive): """ Approves, but does not merge a gerrit change set, which means change set requires another approver. """ slab_logger.info('Adding +1 to gerrit change %s' % gerrit_change_id) try: if not username: username = ctx.get_username() if not project: project = helper_utils.get_current_service(ctx.path)[1] if interactive: project = click.prompt( "Project Name", default=helper_utils.get_current_service(ctx.path)[1]) else: slab_logger.log(25, "current project is " + project) if interactive and not message: message = click.prompt("Message", default=message) gfn = gerrit_functions.GerritFns(username, project, ctx) gfn.change_review(gerrit_change_id, 1, 0, message) except Exception as ex: slab_logger.error(str(ex))
def show_repo(ctx, repo): """ Shows the details of git repos using Gerrit's API. """ username = ctx.get_username() gfx = gerrit_functions.GerritFns(username, repo, ctx) gfx.print_gerrit("summary")
def test_review(self): """ check if we get the review """ gfn = gerrit_functions.GerritFns(self.user, self.prjname, self.ctx) gerrit_functions.GerritFns.instrument_code = True rev = gfn.print_gerrit("", self.review, self.user, "", "") self.assertIsNotNone(rev, "Unable to find the review item {}".format(self.review))
def tearDown(self): """ teardown function removes the directory /tmp/prjdir """ if self.review: gfn = gerrit_functions.GerritFns(self.user, self.prjname, self.ctx) gfn.print_gerrit("", self.review, self.user, "", "abandoned") shutil.rmtree(self.prjdir)
def list_repos(ctx, username): """ Lists repos using Gerrit's API. """ slab_logger.info('Listing repos in Gerrit') if not username: username = ctx.get_username() gfn = gerrit_functions.GerritFns(username, "", ctx) gfn.print_list()
def test_review_number(self): """ test the review number """ gfn = gerrit_functions.GerritFns(self.user, self.prjname, self.ctx) gerrit_functions.GerritFns.instrument_code = True gfn.change_review(self.review, 1, 0, "reviewed") rev = gfn.print_gerrit("", self.review, self.user, "", "") self.assertEqual(rev["currentPatchSet"]["approvals"][0]["value"], "1", "unable to change the code review value")
def test_abandon(self): """ test if able to abandon """ gfn = gerrit_functions.GerritFns(self.user, self.prjname, self.ctx) gerrit_functions.GerritFns.instrument_code = True gfn.code_state(self.review, "abandon", "abandon by unit test") rev = gfn.print_gerrit("", self.review, self.user, "", "abandoned") if rev: self.review = None self.assertIsNotNone(rev, "Unable to find the review item {}".format(self.review))
def find_repo(ctx, search_term): """ Searches through Gerrit's API for a repo using your search term. """ slab_logger.info('Searching Gerrit for repos matching %s' % search_term) username = ctx.get_username() gfn = gerrit_functions.GerritFns(username, "", ctx) repo_list = gfn.repo_list() for elem in repo_list: match_obj = re.search(search_term, elem, re.I) if match_obj: slab_logger.log(25, elem)
def list_reviews(ctx, inout, username): """ Lists reviews using Gerrit's API. """ slab_logger.info('Listing outstanding reviews in Gerrit') if not username: username = ctx.get_username() gfn = gerrit_functions.GerritFns(username, "", ctx) if inout: gfn.print_gerrit(pformat="summary", number=None, owner=username, reviewer="", status="open") else: gfn.print_gerrit(pformat="summary", number=None, owner="", reviewer=username, status="open")
def review_code(ctx, gerrit_change_id, project, username, interactive): """ Display the review """ slab_logger.info('Displaying code for review %s' % gerrit_change_id) try: if not username: username = ctx.get_username() if not project: project = helper_utils.get_current_service(ctx.path)[1] if interactive: project = click.prompt( "Project Name", default=helper_utils.get_current_service(ctx.path)[1]) else: slab_logger.log(25, "current project is " + project) gfn = gerrit_functions.GerritFns(username, project, ctx) gfn.code_review(gerrit_change_id) except Exception as ex: slab_logger.error(str(ex))