Last active
March 4, 2021 19:10
-
-
Save gregorriegler/5b991f859255549bd15e3d61c3842d57 to your computer and use it in GitHub Desktop.
mob.sh-squash-wip-commits
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# GIT_EDITOR replaces the text editor that git would show to let you edit the commit message of the squash | |
# GIT_SEQUENCE_EDITOR replaces the text editor that lists the commits for a interactive rebase | |
# Assuming that you use the default mob.sh wip commit message "mob next [ci-skip]", | |
# this script runs an interactive rebase and squashes commits followed by a "wip commit", | |
# and then edits the commit messages to keep only those of non-wip commits. | |
# So you will end up with all manual commits having the changes of wip commits squashed into them. | |
# If you have only wip commits it might fail the rebase, so make sure there is a manual commit in the end. | |
# | |
# E.g.: | |
# manual-commit-2 | |
# mob next [ci-skip] [ci skip] [skip ci] | |
# manual-commit-1 | |
# mob next [ci-skip] [ci skip] [skip ci] | |
# mob next [ci-skip] [ci skip] [skip ci] | |
# initial import | |
# | |
# Becomes: | |
# manual-commit-2 | |
# manual-commit-1 | |
# initial import | |
GIT_EDITOR="sed -i -r 's/(mob next \[ci-skip\] \[ci skip\] \[skip ci\])/# \0/'" GIT_SEQUENCE_EDITOR="sed -i -r -z 's/([0-9a-f]+ mob next \[ci-skip\] \[ci skip\] \[skip ci\]\n)pick/\1squash/g'" git rebase -i |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment