From 275e1c6b7a0f987eea0f2ab0a28d1ef797299a92 Mon Sep 17 00:00:00 2001 From: guiyom-e Date: Tue, 12 Sep 2023 14:28:18 +0200 Subject: [PATCH] chore: add script to rebase solutions --- .scripts/rebase_solutions.sh | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .scripts/rebase_solutions.sh diff --git a/.scripts/rebase_solutions.sh b/.scripts/rebase_solutions.sh new file mode 100644 index 0000000..b0a0ebe --- /dev/null +++ b/.scripts/rebase_solutions.sh @@ -0,0 +1,37 @@ +!#/bin/bash +# FOR PROJECT MAINTAINERS ONLY +# Update branches +git checkout start-branch || exit 1 +git pull || exit 1 +git checkout solutions || exit 1 +# Rebase on solutions on start-branch +git rebase start-branch || exit 1 + +# Check number of commits +tags=("step2" "step3" "step4" "helpers" "step5" "step6" "step7" "step8" "step9" "step10" "step11" "solutions") +number_of_commits=$(git log --oneline solutions ^start-branch | wc -l) +if [ "$commit_diff" -ne ${#tags[@]} ]; then + echo "The number of commits between start-branch and solutions is not correct, please update the branches or the script" + exit 2 +fi + +# Check tests pass +CI=true yarn test || exit 3 + +# Rebase interactively to re-apply tags +GIT_SEQUENCE_EDITOR="sed -i 's/^pick/edit/g'" git rebase -i start-branch + +# Apply tags to commits +for tag in "${tags[@]}" +do + echo "Tagging $tag" + git tag -f $tag + git rebase --continue +done + +echo "" +echo "=================================================================" +echo "Rebase done, please push changes: " +echo "git push --force-with-lease && git push --force-with-lease --tags" +echo "You may allow force push on the repo settings " +echo "================================================================="