-
Notifications
You must be signed in to change notification settings - Fork 0
/
gitlog2markdown
67 lines (53 loc) · 1.28 KB
/
gitlog2markdown
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
# Generates git log grouped by day and outputs to markdown file
#
# optional parameters
# -a, --author to filter by author
# -s, --since to select start date
# -u, --until to select end date
git-log-to-markdown () {
local NEXT=$(date +%F)
local RED="\x1B[31m"
local YELLOW="\x1B[32m"
local BLUE="\x1B[34m"
local RESET="\x1B[0m"
local SINCE="1970-01-01"
local UNTIL=$NEXT
for i in "$@"
do
case $i in
-a=*|--author=*)
local AUTHOR="${i#*=}"
shift
;;
-s=*|--since=*)
SINCE="${i#*=}"
shift
;;
-u=*|--until=*)
UNTIL="${i#*=}"
shift
;;
*)
# unknown option
;;
esac
done
local LOG_FORMAT=" %Cgreen*%Creset %s"
if [ -z "$AUTHOR" ]
then
LOG_FORMAT="$LOG_FORMAT %Cblue(%an)%Creset"
else
echo "# Gitlog"
fi
git log --no-merges --author="${AUTHOR}" --since="${SINCE}" --until="${UNTIL}" --format="%cd" --date=short | sort -u | while read DATE ; do
local GIT_PAGER=$(git log --no-merges --reverse --format="${LOG_FORMAT} - %h" --since="${DATE} 00:00:00" --until="${DATE} 23:59:59" --author="${AUTHOR}")
if [ ! -z "$GIT_PAGER" ]
then
echo
echo -e "## Version $DATE"
echo -e "${GIT_PAGER}"
fi
done
}
git-log-to-markdown "$@" > ./CHANGELOG.md