Skip to content

Commit

Permalink
chore: update rebase script
Browse files Browse the repository at this point in the history
  • Loading branch information
ZauberNerd committed Sep 9, 2019
1 parent 9b06ed1 commit f035017
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/rebase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,4 @@ jobs:
git remote set-url origin https://x-access-token:[email protected]/xing/hops.git
git config --global user.email "[email protected]"
git config --global user.name "GitHub Action"
git fetch origin master
git fetch origin next
git checkout -b next origin/next
git rebase origin/master || test "$(git diff --name-only --diff-filter=U)" = "yarn.lock" && yarn && git add yarn.lock && git rebase --continue
git push --force-with-lease
./scripts/rebase.sh master next
35 changes: 35 additions & 0 deletions scripts/rebase.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash

set -ex

base_brach=${1:-master}
head_branch=${2:-next}

git fetch origin "$base_brach"
git fetch origin "$head_branch"
git checkout -b "$head_branch" "origin/$head_branch"

is_rebasing=1

exitcode=0 && git rebase "origin/$base_brach" || exitcode=$?
if [[ $exitcode -eq 0 ]]; then is_rebasing=0; fi

while [[ $is_rebasing == 1 ]]; do
if [[ "$(git diff --name-only --diff-filter=U)" == "yarn.lock" ]]; then
yarn install
git add yarn.lock
exitcode=0 && git rebase --continue || exitcode=$?
if [[ $exitcode -eq 0 ]]; then
is_rebasing=0
break
fi
else
break
fi
done

if [[ $is_rebasing -eq 0 ]]; then
git push "$base_brach" "$head_branch" --force-with-lease
else
exit $exitcode
fi

0 comments on commit f035017

Please sign in to comment.