diff --git a/deploy_dev.sh b/deploy_dev.sh index 9ddd5eb..024fa8d 100755 --- a/deploy_dev.sh +++ b/deploy_dev.sh @@ -18,13 +18,13 @@ while getopts m:b:h: flag; do done function checkout_rebase() { + git fetch "$remote" git checkout main || return $? git checkout -b "$branch" - if [ $? -eq 0 ]; then - git fetch "$remote" && git rebase "$remote/main" - else - (git checkout "$branch" && git fetch "$remote" && git rebase "$remote"/"$branch") || (git rebase --abort; return 1) + if [ $? -ne 0 ]; then + (git checkout "$branch" && git rebase "$remote"/"$branch") || (git rebase --abort; return 1) fi + git rebase "$remote/main" || (git rebase --abort; return 1) } function openpr() { @@ -40,7 +40,7 @@ function openpr() { function gpr() { checkout_rebase if [ $? -ne 0 ]; then - echo "Failed to checkout to branch. Check your local changes" + echo "Failed to checkout to branch or rebase. Check your local changes" exit 1 fi git commit "$module" -m "Deploy $branch: $short_commit"