Skip to content

Commit

Permalink
Fetch remote before checking out and rebasing
Browse files Browse the repository at this point in the history
  • Loading branch information
minottic committed Aug 5, 2022
1 parent e562ece commit 20c018c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions deploy_dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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"
Expand Down

0 comments on commit 20c018c

Please sign in to comment.