Commit bef52ff0 authored by tandrii's avatar tandrii Committed by Commit bot

git recipe_module: git new-branch.

R=iannucci@chromium.org,qyearsley@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/2369073002
parent f39c3338
......@@ -409,3 +409,22 @@ class GitApi(recipe_api.RecipeApi):
if not rev_list_args:
rev_list_args = ['--all']
self('bundle', 'create', bundle_path, *rev_list_args, **kwargs)
def new_branch(self, branch, name=None, upstream=None, **kwargs):
"""Runs git new-branch on a Git repository, to be used before git cl upload.
Args:
branch (str): new branch name, which must not yet exist.
name (str): step name.
upstream (str): to origin/master.
kwargs: Forwarded to '__call__'.
"""
env = kwargs.pop('env', {})
env['PATH'] = self.m.path.pathsep.join([
str(self.package_repo_resource()), '%(PATH)s'])
args = ['new-branch', branch]
if upstream:
args.extend(['--upstream', upstream])
if not name:
name = 'git new-branch %s' % branch
return self(*args, name=name, env=env, **kwargs)
......@@ -152,6 +152,32 @@
"cwd": "[SLAVE_BUILD]/src",
"name": "git status cannot_fail_build"
},
{
"cmd": [
"git",
"new-branch",
"refactor"
],
"cwd": "[SLAVE_BUILD]/src",
"env": {
"PATH": "RECIPE_PACKAGE_REPO[depot_tools]:%(PATH)s"
},
"name": "git new-branch refactor"
},
{
"cmd": [
"git",
"new-branch",
"feature",
"--upstream",
"refactor"
],
"cwd": "[SLAVE_BUILD]/src",
"env": {
"PATH": "RECIPE_PACKAGE_REPO[depot_tools]:%(PATH)s"
},
"name": "git new-branch feature"
},
{
"cmd": [
"git",
......
......@@ -152,6 +152,32 @@
"cwd": "[SLAVE_BUILD]/src",
"name": "git status cannot_fail_build"
},
{
"cmd": [
"git",
"new-branch",
"refactor"
],
"cwd": "[SLAVE_BUILD]/src",
"env": {
"PATH": "RECIPE_PACKAGE_REPO[depot_tools]:%(PATH)s"
},
"name": "git new-branch refactor"
},
{
"cmd": [
"git",
"new-branch",
"feature",
"--upstream",
"refactor"
],
"cwd": "[SLAVE_BUILD]/src",
"env": {
"PATH": "RECIPE_PACKAGE_REPO[depot_tools]:%(PATH)s"
},
"name": "git new-branch feature"
},
{
"cmd": [
"git",
......
......@@ -154,6 +154,32 @@
"cwd": "[SLAVE_BUILD]/src",
"name": "git status cannot_fail_build"
},
{
"cmd": [
"git",
"new-branch",
"refactor"
],
"cwd": "[SLAVE_BUILD]/src",
"env": {
"PATH": "RECIPE_PACKAGE_REPO[depot_tools]:%(PATH)s"
},
"name": "git new-branch refactor"
},
{
"cmd": [
"git",
"new-branch",
"feature",
"--upstream",
"refactor"
],
"cwd": "[SLAVE_BUILD]/src",
"env": {
"PATH": "RECIPE_PACKAGE_REPO[depot_tools]:%(PATH)s"
},
"name": "git new-branch feature"
},
{
"cmd": [
"git",
......
......@@ -151,6 +151,32 @@
"cwd": "[SLAVE_BUILD]/src",
"name": "git status cannot_fail_build"
},
{
"cmd": [
"git",
"new-branch",
"refactor"
],
"cwd": "[SLAVE_BUILD]/src",
"env": {
"PATH": "RECIPE_PACKAGE_REPO[depot_tools]:%(PATH)s"
},
"name": "git new-branch refactor"
},
{
"cmd": [
"git",
"new-branch",
"feature",
"--upstream",
"refactor"
],
"cwd": "[SLAVE_BUILD]/src",
"env": {
"PATH": "RECIPE_PACKAGE_REPO[depot_tools]:%(PATH)s"
},
"name": "git new-branch feature"
},
{
"cmd": [
"git",
......
......@@ -152,6 +152,32 @@
"cwd": "[SLAVE_BUILD]/src",
"name": "git status cannot_fail_build"
},
{
"cmd": [
"git",
"new-branch",
"refactor"
],
"cwd": "[SLAVE_BUILD]/src",
"env": {
"PATH": "RECIPE_PACKAGE_REPO[depot_tools]:%(PATH)s"
},
"name": "git new-branch refactor"
},
{
"cmd": [
"git",
"new-branch",
"feature",
"--upstream",
"refactor"
],
"cwd": "[SLAVE_BUILD]/src",
"env": {
"PATH": "RECIPE_PACKAGE_REPO[depot_tools]:%(PATH)s"
},
"name": "git new-branch feature"
},
{
"cmd": [
"git",
......
......@@ -153,6 +153,32 @@
"cwd": "[SLAVE_BUILD]/src",
"name": "git status cannot_fail_build"
},
{
"cmd": [
"git",
"new-branch",
"refactor"
],
"cwd": "[SLAVE_BUILD]/src",
"env": {
"PATH": "RECIPE_PACKAGE_REPO[depot_tools]:%(PATH)s"
},
"name": "git new-branch refactor"
},
{
"cmd": [
"git",
"new-branch",
"feature",
"--upstream",
"refactor"
],
"cwd": "[SLAVE_BUILD]/src",
"env": {
"PATH": "RECIPE_PACKAGE_REPO[depot_tools]:%(PATH)s"
},
"name": "git new-branch feature"
},
{
"cmd": [
"git",
......
......@@ -156,6 +156,32 @@
"@@@STEP_EXCEPTION@@@"
]
},
{
"cmd": [
"git",
"new-branch",
"refactor"
],
"cwd": "[SLAVE_BUILD]/src",
"env": {
"PATH": "RECIPE_PACKAGE_REPO[depot_tools]:%(PATH)s"
},
"name": "git new-branch refactor"
},
{
"cmd": [
"git",
"new-branch",
"feature",
"--upstream",
"refactor"
],
"cwd": "[SLAVE_BUILD]/src",
"env": {
"PATH": "RECIPE_PACKAGE_REPO[depot_tools]:%(PATH)s"
},
"name": "git new-branch feature"
},
{
"cmd": [
"git",
......
......@@ -152,6 +152,32 @@
"cwd": "[SLAVE_BUILD]/src",
"name": "git status cannot_fail_build"
},
{
"cmd": [
"git",
"new-branch",
"refactor"
],
"cwd": "[SLAVE_BUILD]/src",
"env": {
"PATH": "RECIPE_PACKAGE_REPO[depot_tools]:%(PATH)s"
},
"name": "git new-branch refactor"
},
{
"cmd": [
"git",
"new-branch",
"feature",
"--upstream",
"refactor"
],
"cwd": "[SLAVE_BUILD]/src",
"env": {
"PATH": "RECIPE_PACKAGE_REPO[depot_tools]:%(PATH)s"
},
"name": "git new-branch feature"
},
{
"cmd": [
"git",
......
......@@ -225,6 +225,32 @@
"cwd": "[SLAVE_BUILD]/src",
"name": "git status cannot_fail_build"
},
{
"cmd": [
"git",
"new-branch",
"refactor"
],
"cwd": "[SLAVE_BUILD]/src",
"env": {
"PATH": "RECIPE_PACKAGE_REPO[depot_tools]:%(PATH)s"
},
"name": "git new-branch refactor"
},
{
"cmd": [
"git",
"new-branch",
"feature",
"--upstream",
"refactor"
],
"cwd": "[SLAVE_BUILD]/src",
"env": {
"PATH": "RECIPE_PACKAGE_REPO[depot_tools]:%(PATH)s"
},
"name": "git new-branch feature"
},
{
"cmd": [
"git",
......
......@@ -156,6 +156,32 @@
"cwd": "[SLAVE_BUILD]/src",
"name": "git status cannot_fail_build"
},
{
"cmd": [
"git",
"new-branch",
"refactor"
],
"cwd": "[SLAVE_BUILD]/src",
"env": {
"PATH": "RECIPE_PACKAGE_REPO[depot_tools]:%(PATH)s"
},
"name": "git new-branch refactor"
},
{
"cmd": [
"git",
"new-branch",
"feature",
"--upstream",
"refactor"
],
"cwd": "[SLAVE_BUILD]/src",
"env": {
"PATH": "RECIPE_PACKAGE_REPO[depot_tools]:%(PATH)s"
},
"name": "git new-branch feature"
},
{
"cmd": [
"git",
......
......@@ -157,6 +157,32 @@
"cwd": "[SLAVE_BUILD]/src",
"name": "git status cannot_fail_build"
},
{
"cmd": [
"git",
"new-branch",
"refactor"
],
"cwd": "[SLAVE_BUILD]/src",
"env": {
"PATH": "RECIPE_PACKAGE_REPO[depot_tools]:%(PATH)s"
},
"name": "git new-branch refactor"
},
{
"cmd": [
"git",
"new-branch",
"feature",
"--upstream",
"refactor"
],
"cwd": "[SLAVE_BUILD]/src",
"env": {
"PATH": "RECIPE_PACKAGE_REPO[depot_tools]:%(PATH)s"
},
"name": "git new-branch feature"
},
{
"cmd": [
"git",
......
......@@ -154,6 +154,32 @@
"cwd": "[SLAVE_BUILD]/src",
"name": "git status cannot_fail_build"
},
{
"cmd": [
"git",
"new-branch",
"refactor"
],
"cwd": "[SLAVE_BUILD]/src",
"env": {
"PATH": "RECIPE_PACKAGE_REPO[depot_tools]:%(PATH)s"
},
"name": "git new-branch refactor"
},
{
"cmd": [
"git",
"new-branch",
"feature",
"--upstream",
"refactor"
],
"cwd": "[SLAVE_BUILD]/src",
"env": {
"PATH": "RECIPE_PACKAGE_REPO[depot_tools]:%(PATH)s"
},
"name": "git new-branch feature"
},
{
"cmd": [
"git",
......
......@@ -199,6 +199,32 @@
"cwd": "[SLAVE_BUILD]/src",
"name": "git status cannot_fail_build"
},
{
"cmd": [
"git",
"new-branch",
"refactor"
],
"cwd": "[SLAVE_BUILD]/src",
"env": {
"PATH": "RECIPE_PACKAGE_REPO[depot_tools]:%(PATH)s"
},
"name": "git new-branch refactor"
},
{
"cmd": [
"git",
"new-branch",
"feature",
"--upstream",
"refactor"
],
"cwd": "[SLAVE_BUILD]/src",
"env": {
"PATH": "RECIPE_PACKAGE_REPO[depot_tools]:%(PATH)s"
},
"name": "git new-branch feature"
},
{
"cmd": [
"git",
......
......@@ -165,6 +165,32 @@
"cwd": "[SLAVE_BUILD]\\src",
"name": "git status cannot_fail_build"
},
{
"cmd": [
"RECIPE_PACKAGE_REPO[depot_tools]\\git.bat",
"new-branch",
"refactor"
],
"cwd": "[SLAVE_BUILD]\\src",
"env": {
"PATH": "RECIPE_PACKAGE_REPO[depot_tools];%(PATH)s"
},
"name": "git new-branch refactor"
},
{
"cmd": [
"RECIPE_PACKAGE_REPO[depot_tools]\\git.bat",
"new-branch",
"feature",
"--upstream",
"refactor"
],
"cwd": "[SLAVE_BUILD]\\src",
"env": {
"PATH": "RECIPE_PACKAGE_REPO[depot_tools];%(PATH)s"
},
"name": "git new-branch feature"
},
{
"cmd": [
"RECIPE_PACKAGE_REPO[depot_tools]\\git.bat",
......
......@@ -152,6 +152,32 @@
"cwd": "[SLAVE_BUILD]/src",
"name": "git status cannot_fail_build"
},
{
"cmd": [
"git",
"new-branch",
"refactor"
],
"cwd": "[SLAVE_BUILD]/src",
"env": {
"PATH": "RECIPE_PACKAGE_REPO[depot_tools]:%(PATH)s"
},
"name": "git new-branch refactor"
},
{
"cmd": [
"git",
"new-branch",
"feature",
"--upstream",
"refactor"
],
"cwd": "[SLAVE_BUILD]/src",
"env": {
"PATH": "RECIPE_PACKAGE_REPO[depot_tools]:%(PATH)s"
},
"name": "git new-branch feature"
},
{
"cmd": [
"git",
......
......@@ -154,6 +154,32 @@
"cwd": "[SLAVE_BUILD]/src",
"name": "git status cannot_fail_build"
},
{
"cmd": [
"git",
"new-branch",
"refactor"
],
"cwd": "[SLAVE_BUILD]/src",
"env": {
"PATH": "RECIPE_PACKAGE_REPO[depot_tools]:%(PATH)s"
},
"name": "git new-branch refactor"
},
{
"cmd": [
"git",
"new-branch",
"feature",
"--upstream",
"refactor"
],
"cwd": "[SLAVE_BUILD]/src",
"env": {
"PATH": "RECIPE_PACKAGE_REPO[depot_tools]:%(PATH)s"
},
"name": "git new-branch feature"
},
{
"cmd": [
"git",
......
......@@ -153,6 +153,32 @@
"cwd": "[SLAVE_BUILD]/src",
"name": "git status cannot_fail_build"
},
{
"cmd": [
"git",
"new-branch",
"refactor"
],
"cwd": "[SLAVE_BUILD]/src",
"env": {
"PATH": "RECIPE_PACKAGE_REPO[depot_tools]:%(PATH)s"
},
"name": "git new-branch refactor"
},
{
"cmd": [
"git",
"new-branch",
"feature",
"--upstream",
"refactor"
],
"cwd": "[SLAVE_BUILD]/src",
"env": {
"PATH": "RECIPE_PACKAGE_REPO[depot_tools]:%(PATH)s"
},
"name": "git new-branch feature"
},
{
"cmd": [
"git",
......
......@@ -67,6 +67,11 @@ def RunSteps(api):
api.git('status', name='git status cannot_fail_build',
can_fail_build=False)
# You should run git new-branch before you upload something with git cl.
api.git.new_branch('refactor') # Upstream is origin/master by default.
# And use upstream kwarg to set up different upstream for tracking.
api.git.new_branch('feature', upstream='refactor')
# You can use api.git.rebase to rebase the current branch onto another one
api.git.rebase(name_prefix='my repo', branch='origin/master',
dir_path=api.path['checkout'],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment