From 95226d4cd09790c3628ab8474cfdb21bf3fe99ad Mon Sep 17 00:00:00 2001 From: Diana Picus Date: Wed, 1 Nov 2017 13:16:54 +0100 Subject: llvm push: Print remote branch name after pushing Get llvm.py push to print the name of the remote branch that it has pushed to. This is helpful so developers don't need to guess what namespaces have been prepended to the branch name, and also serves as quick visual confirmation. This required a bit of refactoring, since the name of the branch was computed when needed. We now compute it separately and pass it in to the function that pushes the branch. We rely on the fact that the branch name will be the same for all the subprojects involved. Most of the changes are mechanical, to account for this refactoring (including new names for some of the existing functions, which make more sense in this new context). Change-Id: Id7e496bcded60080803e3a850d73329428bc3bac --- scripts/llvm.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'scripts/llvm.py') diff --git a/scripts/llvm.py b/scripts/llvm.py index 2252ab2..3244bde 100644 --- a/scripts/llvm.py +++ b/scripts/llvm.py @@ -3,7 +3,11 @@ import os from sys import exit -from modules.llvm import LLVMSubproject, LLVMSourceConfig, push_current_branch +from modules.llvm import LLVMSubproject +from modules.llvm import LLVMSourceConfig +from modules.llvm import get_remote_branch +from modules.llvm import push_branch + from linaropy.git.clone import Clone from linaropy.proj import Proj @@ -66,7 +70,7 @@ def projects(args): dump_config(config) -def push_branch(args): +def push_current_branch(args): """Push current branch to origin.""" proj = Proj() @@ -74,13 +78,18 @@ def push_branch(args): llvm_worktree_root = get_worktree_root(args.env) config = LLVMSourceConfig(proj, llvm_worktree_root) - llvmBranch = Clone(proj, llvm_worktree_root).getbranch() + llvm_worktree = Clone(proj, llvm_worktree_root) + local_branch = llvm_worktree.getbranch() try: - config.for_each_enabled(partial(push_current_branch, proj)) - except RuntimeError as exc: + remote_branch = get_remote_branch(llvm_worktree, local_branch) + config.for_each_enabled(partial(push_branch, proj, local_branch, + remote_branch)) + print("Pushed to {}".format(remote_branch)) + except (EnvironmentError, RuntimeError) as exc: die("Failed to push branch because: " + str(exc) + str(exc.__cause__)) + ########################################################################## # Command line parsing # ########################################################################## @@ -127,7 +136,7 @@ projs.add_argument( push = subcommands.add_parser( "push", help="Push current branch to origin linaro-local//, for all linked subprojects.") -push.set_defaults(run_command=push_branch) +push.set_defaults(run_command=push_current_branch) args = options.parse_args() args.run_command(args) -- cgit v1.2.3