aboutsummaryrefslogtreecommitdiff
path: root/scripts/llvm.py
diff options
context:
space:
mode:
authorDiana Picus <diana.picus@linaro.org>2017-11-01 13:16:54 +0100
committerDiana Picus <diana.picus@linaro.org>2017-11-03 11:24:26 +0100
commit95226d4cd09790c3628ab8474cfdb21bf3fe99ad (patch)
treec1ae10a0a3db9a7a7aca58a5da77f5ca434f1855 /scripts/llvm.py
parent7fefe1e34549a439f42facfa1bf769b35a48cffe (diff)
downloadlinaro-scripts-95226d4cd09790c3628ab8474cfdb21bf3fe99ad.tar.gz
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
Diffstat (limited to 'scripts/llvm.py')
-rw-r--r--scripts/llvm.py21
1 files changed, 15 insertions, 6 deletions
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/<user>/<branch>, 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)