Compare commits

..
Author SHA1 Message Date
dzu
7bd8c658eb ench: add a message mentioning squashed commits 2026-02-21 06:18:58 +00:00
dzu
af0085d31e fix: add git identity 2026-02-21 06:18:35 +00:00

13
main.sh
View file

@ -31,14 +31,25 @@ TMP_BRANCH="tmp-$RANDOM"
git checkout -b $TMP_BRANCH git checkout -b $TMP_BRANCH
git checkout $BRANCH git checkout $BRANCH
# use current branch last commit's author as the git identity
GIT_NAME=$(git show -s --format='%an' HEAD)
GIT_EMAIL=$(git show -s --format='%ae' HEAD)
# reset current branch to the root # reset current branch to the root
ROOT_HASH=$(git rev-list --max-parents=0 HEAD) ROOT_HASH=$(git rev-list --max-parents=0 HEAD)
git reset --hard $ROOT_HASH git reset --hard $ROOT_HASH
# generate changes
MESSAGE=''
for rev in $(git rev-list $ROOT_HASH..$TMP_BRANCH); do
MESSAGE="$(git show --no-color --format=fuller --no-patch HEAD)\n$MESSAGE"
done
MESSAGE="Squashed the branch at $(date)\n$MESSAGE"
# merge-squash newest changes from the temporary branch # merge-squash newest changes from the temporary branch
git merge --squash $TMP_BRANCH git merge --squash $TMP_BRANCH
git add . git add .
git commit -m "$(date)" git commit -c user.email=$GIT_EMAIL -c user.name=$GIT_NAME -m $MESSAGE
# remove temporary branch # remove temporary branch
git branch -D $TMP_BRANCH git branch -D $TMP_BRANCH