aboutsummaryrefslogtreecommitdiff
path: root/helpers/git-push
diff options
context:
space:
mode:
authorRenato Golin <rengolin@gmail.com>2016-04-26 11:02:23 +0100
committerRenato Golin <rengolin@gmail.com>2016-04-26 11:02:23 +0100
commit94cc104f044261f74fbff3ff587855df1a05f64d (patch)
tree7c6664fdf7e7fab54fea926b1fc6196a09b6540f /helpers/git-push
Initial Commit, moving from dev-private and removing private stuff
Diffstat (limited to 'helpers/git-push')
-rwxr-xr-xhelpers/git-push42
1 files changed, 42 insertions, 0 deletions
diff --git a/helpers/git-push b/helpers/git-push
new file mode 100755
index 0000000..2869dcf
--- /dev/null
+++ b/helpers/git-push
@@ -0,0 +1,42 @@
+#!/usr/bin/env bash
+
+# This script pushes the current branch to the origin repository.
+# As an added bonus, it refreshes the local master branch from
+# the origin, to make sure your branch is in sync with the master of the
+# repo you're pushing to.
+#
+# Syntax: git-push [branch (default=current)]
+
+. llvm-common
+
+branch=
+if [[ $1 != '' ]]; then
+ if [[ `git branch | grep $1` = '' ]]; then
+ echo "Branch '$1' doesn't exist in this repository"
+ exit 2
+ fi
+ branch=$1
+else
+ branch=`get_branch`
+fi
+
+if [[ $branch = 'master' ]]; then
+ echo "Can't push the master branch."
+ echo "Use git-refresh instead."
+ exit 1
+fi
+
+prefix="linaro-local/"
+if echo $branch | grep -q linaro-local; then
+ prefix=""
+fi
+
+echo " ++ Refresh Master from Upstream"
+safe_run git-refresh
+
+echo " ++ Rebase to new master"
+safe_run git checkout $branch
+safe_run git rebase master
+
+echo " ++ Push $branch to Origin"
+safe_run git push -u origin +$branch:$prefix$branch