@@ -22,6 +22,10 @@ source "$(dirname "${BASH_SOURCE[0]}")/includer.sh"
2222
2323options::standard
2424options::add -o l -d " add hyperlinks to commits" -x ADD_LINKS
25+ options::add -o f -d " from date" -a -e FROM_DATE
26+ options::add -o t -d " to date" -a -e TO_DATE
27+ options::add -o d -d " show commit date" -x SHOW_DATE
28+
2529options::parse_available " $@ "
2630
2731export GIT_PAGER=cat
@@ -38,15 +42,39 @@ function ::fromto() {
3842 return
3943 fi
4044 if [ " $ADD_LINKS " = " true" ] && [ -n " $base_url " ]; then
41- git::cmd log " $from " ..." $to " --no-merges \
42- --pretty=format:" * %s [view commit]($base_url /%H)"
45+ if [ " $SHOW_DATE " != " true" ]; then
46+ git::cmd log " $from " ..." $to " --no-merges \
47+ --pretty=format:" * %s [view commit]($base_url /%H)"
48+ else
49+ git::cmd log " $from " ..." $to " --no-merges \
50+ --pretty=format:" * %ci - %s [view commit]($base_url /%H)"
51+ fi
4352 else
44- git::cmd log " $from " ..." $to " --no-merges --pretty=format:" * %s"
53+ if [ " $SHOW_DATE " != " true" ]; then
54+ git::cmd log " $from " ..." $to " --no-merges --pretty=format:" * %s"
55+ else
56+ git::cmd log " $from " ..." $to " --no-merges --pretty=format:" * %ci - %s"
57+ fi
58+
4559 fi
4660 echo
4761 echo
4862}
4963
64+ function ::current_branch() {
65+ git::cmd rev-parse --abbrev-ref HEAD
66+ }
67+
68+ function ::date_to_commit_before() {
69+ local theDate=${1:? }
70+ git::cmd rev-list -n 1 --first-parent --before=" $theDate " " $( ::current_branch) "
71+ }
72+
73+ function ::date_to_commit_after() {
74+ local theDate=${1:? }
75+ git::cmd rev-list -n 1 --first-parent --before=" $theDate " " $( ::current_branch) "
76+ }
77+
5078function ::full() {
5179 local later_tag=
5280 echo " # CHANGELOG"
@@ -82,4 +110,21 @@ function ::full() {
82110 done
83111}
84112
85- ::full
113+ if [ -n " $TO_DATE " ]; then
114+ to_commit=$( ::date_to_commit_before " $TO_DATE " )
115+ fi
116+
117+ if [ -n " $FROM_DATE " ]; then
118+ from_commit=$( ::date_to_commit_after " $FROM_DATE " )
119+ fi
120+
121+ if [ -n " $FROM_DATE " ] || [ -n " $TO_DATE " ]; then
122+ if [ -z " $to_commit " ]; then
123+ echo " No change history in the requested range"
124+ exit 0
125+ else
126+ ::fromto " $from_commit " " $to_commit "
127+ fi
128+ else
129+ ::full
130+ fi
0 commit comments