Files
chromium_depot_tools/recipes/recipe_modules/git_cl/api.py
Brian Sheedy 9879712089 Run recipe git_cl under Python 3
Makes the git_cl recipe module use vpython3 instead of vpython, as
the latter breaks when running on builders with the omit_python2
experiment.

Bug: 1366965
Recipe-Nontrivial-Roll: build
Recipe-Nontrivial-Roll: build_limited
Recipe-Nontrivial-Roll: chromiumos
Recipe-Nontrivial-Roll: infra
Change-Id: I2306e97dbc7b75201024b5dcf1892787185d5f77
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3968801
Auto-Submit: Brian Sheedy <bsheedy@chromium.org>
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
Commit-Queue: Robbie Iannucci <iannucci@chromium.org>
2022-10-21 20:18:52 +00:00

50 lines
1.6 KiB
Python

# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from recipe_engine import recipe_api
import string
class GitClApi(recipe_api.RecipeApi):
def __call__(self, subcmd, args, name=None, **kwargs):
if not name:
name = 'git_cl ' + subcmd
if kwargs.get('suffix'):
name = name + ' (%s)' % kwargs.pop('suffix')
my_loc = self.c.repo_location if self.c else None
cmd = ['vpython3', self.repo_resource('git_cl.py'), subcmd] + args
with self.m.context(cwd=self.m.context.cwd or my_loc):
return self.m.step(name, cmd, **kwargs)
def get_description(self, patch_url=None, **kwargs):
"""DEPRECATED. Consider using gerrit.get_change_description instead."""
args = ['-d']
if patch_url:
args.append(patch_url)
return self('description', args, stdout=self.m.raw_io.output(), **kwargs)
def set_description(self, description, patch_url=None, **kwargs):
args = ['-n', '-']
if patch_url:
args.append(patch_url)
return self(
'description', args, stdout=self.m.raw_io.output(),
stdin=self.m.raw_io.input_text(description),
name='git_cl set description', **kwargs)
def upload(self, message, upload_args=None, **kwargs):
upload_args = upload_args or []
upload_args.extend(['--message-file', self.m.raw_io.input_text(message)])
return self('upload', upload_args, **kwargs)
def issue(self, **kwargs):
return self('issue', [], stdout=self.m.raw_io.output(), **kwargs)