Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7bd8c658eb | |||
| af0085d31e |
1 changed files with 12 additions and 1 deletions
13
main.sh
13
main.sh
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue