shoestrap/assets/default/bin/git-monthly

40 lines
826 B
Plaintext
Raw Normal View History

2017-04-27 17:52:49 +00:00
#! /bin/bash
##########################
# Author: ViViDboarder
# Returns a git log of any commits in the current or given month
##########################
month=$1
year=$2
if [ -z "$month" ]; then
echo "usage: git-monthly <month> <year>"
echo "eg: git-monthly 4 2019"
exit 1
fi
2017-04-27 17:52:49 +00:00
if [[ "$month" == "" ]]; then
# Get the current month
month=$(date "+%m")
fi
if [[ "$year" == "" ]]; then
# Get the current year
year=$(date "+%Y")
fi
# Get the next month
if [[ "$month" == "12" ]]; then
# If December, loop to Jan of next year
nmonth="1"
nyear=$((year + 1))
else
# Otherwise, next month of this year
nmonth=$((month + 1))
nyear=$year
fi
# Get the git log between the target month and the next month
git log --before="{${nyear}-${nmonth}-1}" --after="{${year}-${month}-1}"