33# Function to print help and manage arguments
44eval $(
55 zz_args " Fix git emoji" $0 " $@ " << -help
6- f - force allow overwritting pushed history
7- - sha sha sha commit to fix from after
6+ f - force allow overwritting pushed history
7+ p - push push changes after rewriting history
8+ - sha sha sha commit to fix from after
89 help
910)
1011
@@ -14,6 +15,12 @@ cd "$(git rev-parse --show-toplevel)" >/dev/null
1415# Fetch updates from the remote repository
1516git fetch --progress --prune --recurse-submodules=no origin > /dev/null
1617
18+ # Make sure we don't have uncommitted changes
19+ if ! git diff-index --quiet HEAD --; then
20+ zz_log e " You have uncommitted changes. Please commit or stash them before running this script."
21+ exit 1
22+ fi
23+
1724# Retrieve the commit SHA to fixup
1825sha=$( git getcommit $force $sha )
1926
@@ -25,3 +32,14 @@ git filter-branch --msg-filter 'npx --yes devmoji -t "$(cat)"' --tag-name-filter
2532rm -rf .git/refs/original/
2633git reflog expire --expire=now --all
2734git gc --prune=now
35+
36+ # Push changes if the push flag is set
37+ if [ " $push " = true ]; then
38+ if [ " $force " = true ]; then
39+ git push --force --tags origin ' refs/heads/*'
40+ else
41+ git push --force-with-lease --tags origin ' refs/heads/*'
42+ fi
43+ fi
44+
45+ zz_log s " Git emoji fixup completed successfully."
0 commit comments