Skip to content

Commit 2aeeb17

Browse files
committed
chore: add script to rebase solutions
1 parent 07cf2f6 commit 2aeeb17

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

.scripts/rebase_solutions.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
# FOR PROJECT MAINTAINERS ONLY
3+
4+
set -e
5+
# Update branches
6+
git checkout start-branch
7+
git pull
8+
git checkout solutions
9+
# Rebase on solutions on start-branch
10+
git rebase start-branch
11+
12+
# Check number of commits
13+
tags=("step2" "step3" "step4" "helpers" "step5" "step6" "step7" "step8" "step9" "step10" "step11" "_solution_")
14+
number_of_commits=$(git log --oneline solutions ^start-branch | wc -l)
15+
if [ "$commit_diff" -ne ${#tags[@]} ]; then
16+
echo "The number of commits between start-branch and solutions is not correct, please update the branches or the script"
17+
exit 2
18+
fi
19+
20+
# Check tests pass
21+
CI=true yarn test || exit 3
22+
23+
# Rebase interactively to re-apply tags
24+
GIT_SEQUENCE_EDITOR="sed -i 's/^pick/edit/g'" git rebase -i start-branch
25+
26+
# Apply tags to commits
27+
for tag in "${tags[@]}"
28+
do
29+
echo "Tagging $tag"
30+
git tag -f $tag
31+
git rebase --continue
32+
done
33+
34+
echo ""
35+
echo "================================================================="
36+
echo "Rebase done, please push changes: "
37+
echo "git push --force-with-lease && git push --force-with-lease --tags"
38+
echo "You may allow force push on the repo settings "
39+
echo "================================================================="

0 commit comments

Comments
 (0)