forked from henishv/ngx-uploader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
git-changelog.sh
executable file
·27 lines (23 loc) · 953 Bytes
/
git-changelog.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/sh
CHANGELOG_FILE=CHANGELOG.md
FORMAT=" * [%h](../../commit/%h) - %s"
if test "$CHANGELOG_FILE" != ""; then
rm -rf $CHANGELOG_FILE
touch $CHANGELOG_FILE
fi
echo "\nCHANGELOG\n=========\n\n" >> $CHANGELOG_FILE
git for-each-ref --sort='*authordate' --format='%(tag)' refs/tags |gtac |grep -v '^$' | while read TAG ; do
TAG_DATE=$(git log -1 --pretty=tformat:%cd --date=short $TAG)
if [ $NEXT ];then
TAG_DATE=$(git log -1 --pretty=tformat:%cd --date=short $NEXT)
echo "\n\n#### $NEXT / $TAG_DATE" >> $CHANGELOG_FILE
else
echo "#### [Current] / $TAG_DATE" >> $CHANGELOG_FILE
fi
GIT_PAGER=cat git log --pretty=format:"$FORMAT" $TAG..$NEXT >> $CHANGELOG_FILE
NEXT=$TAG
done
FIRST=$(git tag -l | head -1)
TAG_DATE=$(git log -1 --pretty=tformat:%cd --date=short $FIRST)
echo "\n\n#### $FIRST / $TAG_DATE" >> $CHANGELOG_FILE
GIT_PAGER=cat git log --pretty=format:"$FORMAT" $FIRST >> $CHANGELOG_FILE