Using this script to get day by day changelog
echo "CHANGELOG"
echo ----------------------
git log --no-merges --format="%cd" --date=short | sort -u -r | while read DATE ; do
echo
echo [$DATE]
GIT_PAGER=cat git log --no-merges --format=" * %s" --since="2019-12-15 00:00:00" --until="$DATE 24:00:00"
done
This will echo ECHO even if i don't want to get those commits,
My question here i don't want to get those date before 2019-12-15. I only want to print the date from 2019-12-15 to this day.
Right now i'm getting what i want but whit the previous date empty, i know it's related to the while condition.
So my question is to only get the date and the commit since 2019-12-15.
at the moment i'm getting All the date before 2019-12-15 ( without their commits.
And also getting all the commits + date since 2019-12-15 ( This is perfect)
[2019-17-12]
----COMMITS--
[2019-16-12]
----COMMITS--
[2019-15-12]
--COMMITS--
[2019-14-12]
[2019-13-12]
[2019-12-12]
[2019-11-12]
I want it like this
[2019-17-12]
----COMMITS--
[2019-16-12]
----COMMITS--
[2019-15-12]
--COMMITS--
Thank you
Capture the output first. If it's empty, exit with 0. If it's not, print the date and the output.
echo "CHANGELOG"
echo ----------------------
git log --no-merges --format="%cd" --date=short | sort -u -r | while read DATE ; do
output=$(GIT_PAGER=cat git log --no-merges --format=" * %s" --since="2019-12-15 00:00:00" --until="$DATE 24:00:00")
if [[ -z $output ]];then
exit 0
else
echo
echo [$DATE]
echo "$output"
fi
done
And after reading @phd comment, I realize that you can just add --since="2019-12-15 00:00:00"
to the first git log
.
echo "CHANGELOG"
echo ----------------------
git log --no-merges --format="%cd" --date=short --since="2019-12-15 00:00:00"| sort -u -r | while read DATE ; do
echo
echo [$DATE]
GIT_PAGER=cat git log --no-merges --format=" * %s" --since="2019-12-15 00:00:00" --until="$DATE 24:00:00"
done