mirror of https://github.com/zulip/zulip.git
Add tool for deploying branches to origin/master
(imported from commit 0fb0b5d37ee5c8486791e55fa731d207477ba248)
This commit is contained in:
parent
bc67d9d1d7
commit
3e1802bcea
|
@ -0,0 +1,38 @@
|
|||
#!/bin/bash
|
||||
|
||||
function error_out {
|
||||
echo -en '\e[0;31m'
|
||||
echo $1
|
||||
echo -en '\e[0m'
|
||||
exit 1
|
||||
}
|
||||
|
||||
status=$(git status --porcelain | grep -v '^??')
|
||||
[ ! -z "$status" ] && error_out "Working directory or index not clean"
|
||||
|
||||
old_ref=$(git rev-list --max-count=1 HEAD)
|
||||
branch=$1
|
||||
branch_ref=$(git rev-list --max-count=1 $branch)
|
||||
|
||||
[ $? -ne 0 ] && error_out "Unknown branch: $branch"
|
||||
|
||||
if [ "$old_ref" == "$branch_ref" ]; then
|
||||
new_ref=master
|
||||
else
|
||||
new_ref=$old_ref
|
||||
fi
|
||||
|
||||
[ -z "$branch" ] && error_out "You must specify a branch name to deploy"
|
||||
|
||||
git fetch -p
|
||||
|
||||
git rebase origin/master $branch
|
||||
[ $? -ne 0 ] && error_out "Rebase onto origin/master failed"
|
||||
|
||||
git push . HEAD:master
|
||||
git push origin master
|
||||
[ $? -ne 0 ] && error_out "Push of master to origin/master failed"
|
||||
|
||||
git checkout $new_ref
|
||||
git branch -D $branch
|
||||
git push origin :$branch
|
Loading…
Reference in New Issue