Compare commits
1 changed files with 1 additions and 12 deletions
13
main.sh
13
main.sh
|
|
@ -31,25 +31,14 @@ 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 -c user.email=$GIT_EMAIL -c user.name=$GIT_NAME -m $MESSAGE
|
git commit -m "$(date)"
|
||||||
|
|
||||||
# remove temporary branch
|
# remove temporary branch
|
||||||
git branch -D $TMP_BRANCH
|
git branch -D $TMP_BRANCH
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue