Add git_cl recipe module.
BUG=607359 Review-Url: https://codereview.chromium.org/1925873002 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@300372 0039d316-1c4b-4281-b951-d872f2087c98changes/60/343160/1
parent
cf1974811b
commit
28216cd14b
@ -0,0 +1,4 @@
|
||||
DEPS = [
|
||||
'recipe_engine/raw_io',
|
||||
'recipe_engine/step',
|
||||
]
|
||||
@ -0,0 +1,25 @@
|
||||
# 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
|
||||
|
||||
class GitClApi(recipe_api.RecipeApi):
|
||||
def __call__(self, subcmd, args, name=None, **kwargs):
|
||||
if not name:
|
||||
name = 'git_cl ' + subcmd
|
||||
if 'cwd' not in kwargs:
|
||||
kwargs['cwd'] = (self.c and self.c.repo_location) or None
|
||||
|
||||
return self.m.step(
|
||||
name, [self.package_repo_resource('git_cl.py')] + args, **kwargs)
|
||||
|
||||
def get_description(self, **kwargs):
|
||||
return self('description', ['-d'], stdout=self.m.raw_io.output(), **kwargs)
|
||||
|
||||
def set_description(self, description, **kwargs):
|
||||
return self(
|
||||
'description', ['-n', '-'],
|
||||
stdout=self.m.raw_io.output(),
|
||||
stdin=self.m.raw_io.input(data=description),
|
||||
name='git_cl set description', **kwargs)
|
||||
@ -0,0 +1,22 @@
|
||||
# Copyright 2013 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.
|
||||
|
||||
import types
|
||||
|
||||
from recipe_engine.config import config_item_context, ConfigGroup, BadConf
|
||||
from recipe_engine.config import Single
|
||||
from recipe_engine.config_types import Path
|
||||
|
||||
def BaseConfig(**_kwargs):
|
||||
return ConfigGroup(
|
||||
repo_location=Single(Path)
|
||||
)
|
||||
|
||||
config_ctx = config_item_context(BaseConfig)
|
||||
|
||||
@config_ctx()
|
||||
def basic(c):
|
||||
pass
|
||||
|
||||
|
||||
@ -0,0 +1,66 @@
|
||||
[
|
||||
{
|
||||
"cmd": [
|
||||
"RECIPE_PACKAGE_REPO[depot_tools]/git_cl.py",
|
||||
"-d"
|
||||
],
|
||||
"cwd": "[TMP_BASE]/fakee_tmp_1",
|
||||
"name": "git_cl description",
|
||||
"stdout": "/path/to/tmp/"
|
||||
},
|
||||
{
|
||||
"cmd": [
|
||||
"echo",
|
||||
"hi"
|
||||
],
|
||||
"name": "echo"
|
||||
},
|
||||
{
|
||||
"cmd": [
|
||||
"RECIPE_PACKAGE_REPO[depot_tools]/git_cl.py",
|
||||
"-d"
|
||||
],
|
||||
"cwd": "[TMP_BASE]/fakerepo_tmp_2",
|
||||
"name": "git_cl description (2)",
|
||||
"stdout": "/path/to/tmp/"
|
||||
},
|
||||
{
|
||||
"cmd": [
|
||||
"echo",
|
||||
"hey"
|
||||
],
|
||||
"name": "echo (2)"
|
||||
},
|
||||
{
|
||||
"cmd": [
|
||||
"RECIPE_PACKAGE_REPO[depot_tools]/git_cl.py",
|
||||
"-n",
|
||||
"-"
|
||||
],
|
||||
"cwd": "[TMP_BASE]/fakerepo_tmp_2",
|
||||
"name": "git_cl set description",
|
||||
"stdin": "new description woo",
|
||||
"stdout": "/path/to/tmp/"
|
||||
},
|
||||
{
|
||||
"cmd": [
|
||||
"RECIPE_PACKAGE_REPO[depot_tools]/git_cl.py",
|
||||
"-d"
|
||||
],
|
||||
"cwd": "[TMP_BASE]/fakerepo_tmp_2",
|
||||
"name": "git_cl description (3)",
|
||||
"stdout": "/path/to/tmp/"
|
||||
},
|
||||
{
|
||||
"cmd": [
|
||||
"echo",
|
||||
"new description woo"
|
||||
],
|
||||
"name": "echo (3)"
|
||||
},
|
||||
{
|
||||
"name": "$result",
|
||||
"recipe_result": null,
|
||||
"status_code": 0
|
||||
}
|
||||
]
|
||||
@ -0,0 +1,41 @@
|
||||
# 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.config_types import Path
|
||||
|
||||
|
||||
DEPS = [
|
||||
'git_cl',
|
||||
'recipe_engine/path',
|
||||
'recipe_engine/raw_io',
|
||||
'recipe_engine/step',
|
||||
]
|
||||
|
||||
|
||||
def RunSteps(api):
|
||||
res = api.git_cl.get_description(cwd=api.path.mkdtemp('fakee'))
|
||||
# Look ma, no hands! (Can pass in the cwd without configuring git_cl).
|
||||
api.step('echo', ['echo', res.stdout])
|
||||
|
||||
api.git_cl.set_config('basic')
|
||||
api.git_cl.c.repo_location = api.path.mkdtemp('fakerepo')
|
||||
|
||||
api.step('echo', ['echo', api.git_cl.get_description().stdout])
|
||||
|
||||
api.git_cl.set_description("new description woo")
|
||||
|
||||
api.step('echo', ['echo', api.git_cl.get_description().stdout])
|
||||
|
||||
def GenTests(api):
|
||||
yield (
|
||||
api.test('basic') +
|
||||
api.override_step_data(
|
||||
'git_cl description', stdout=api.raw_io.output('hi')) +
|
||||
api.override_step_data(
|
||||
'git_cl description (2)', stdout=api.raw_io.output('hey')) +
|
||||
api.override_step_data(
|
||||
'git_cl description (3)', stdout=api.raw_io.output(
|
||||
'new description woo'))
|
||||
)
|
||||
|
||||
Loading…
Reference in New Issue