Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(324)

Unified Diff: recipe_modules/git/api.py

Issue 2369073002: git recipe_module: git new-branch. (Closed)
Patch Set: Review. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | recipe_modules/git/example.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: recipe_modules/git/api.py
diff --git a/recipe_modules/git/api.py b/recipe_modules/git/api.py
index dddb1de8001f21eaadc096e6fece09797b1841c2..746c18fe5f33bff563519a39fe4bb06b99aca027 100644
--- a/recipe_modules/git/api.py
+++ b/recipe_modules/git/api.py
@@ -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)
« no previous file with comments | « no previous file | recipe_modules/git/example.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698