diff --git a/src/squash_fixups.sh b/src/squash_fixups.sh new file mode 100644 index 0000000..3d9d0ea --- /dev/null +++ b/src/squash_fixups.sh @@ -0,0 +1,20 @@ +# /etc/profile.d/squash-fixups.sh + +if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then + echo "This script should be sourced, not executed." + exit 1 +fi + +# Function to automate squashing and rebasing for commits starting with "fixup!" +squash_fixups() { + # Ensure we are in a git repository + if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then + echo "Not inside a git repository." + return 1 + fi + + # Perform a non-interactive rebase with autosquash + git rebase --autosquash --autostash --keep-empty --rebase-merges -i "$(git merge-base HEAD $(git rev-list --no-walk HEAD))" < /dev/null + + echo "Rebase and squash completed for commits starting with 'fixup!'." +}