Renato Golin | 94cc104 | 2016-04-26 11:02:23 +0100 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | # This script pushes the current branch to the origin repository. |
| 4 | # As an added bonus, it refreshes the local master branch from |
| 5 | # the origin, to make sure your branch is in sync with the master of the |
| 6 | # repo you're pushing to. |
| 7 | # |
| 8 | # Syntax: git-push [branch (default=current)] |
| 9 | |
| 10 | . llvm-common |
| 11 | |
| 12 | branch= |
| 13 | if [[ $1 != '' ]]; then |
| 14 | if [[ `git branch | grep $1` = '' ]]; then |
| 15 | echo "Branch '$1' doesn't exist in this repository" |
| 16 | exit 2 |
| 17 | fi |
| 18 | branch=$1 |
| 19 | else |
| 20 | branch=`get_branch` |
| 21 | fi |
| 22 | |
| 23 | if [[ $branch = 'master' ]]; then |
| 24 | echo "Can't push the master branch." |
| 25 | echo "Use git-refresh instead." |
| 26 | exit 1 |
| 27 | fi |
| 28 | |
| 29 | prefix="linaro-local/" |
| 30 | if echo $branch | grep -q linaro-local; then |
| 31 | prefix="" |
| 32 | fi |
| 33 | |
| 34 | echo " ++ Refresh Master from Upstream" |
| 35 | safe_run git-refresh |
| 36 | |
| 37 | echo " ++ Rebase to new master" |
| 38 | safe_run git checkout $branch |
| 39 | safe_run git rebase master |
| 40 | |
| 41 | echo " ++ Push $branch to Origin" |
| 42 | safe_run git push -u origin +$branch:$prefix$branch |