-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmonth.sh
executable file
·57 lines (38 loc) · 957 Bytes
/
month.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
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
#!/bin/bash -l
usage(){ cat << EOU
mo.sh : git commit messages by month or year for this year and last
=====================================================================
::
o
./mo.sh -h # this help message
./mo.sh 0 # all this year
./mo.sh -0 # all last year
./mo.sh 1 # this year january
./mo.sh -1 # last year january
./mo.sh -2 # last year february
./mo.sh -12 # last year december
EOU
}
mo=${1:-1}
rev=${REV:-0}
year=$(date +"%Y")
lastyear=$(( $year - 1 ))
if [ "${mo:0:1}" == "-" ]; then
mo=${mo:1}
logyear=$lastyear
else
logyear=$year
fi
[ "$mo" == "h" ] && usage && exit 0
month=$(printf "%0.2d" $mo)
if [ "$mo" == "0" ]; then
cmd="git lg --after $logyear-01-01 --before $logyear-12-31"
else
cmd="git lg --after $logyear-$month-01 --before $logyear-$month-31"
fi
if [ "$rev" == "1" ]; then
cmd="$cmd | tail -r"
fi
echo $cmd
eval $cmd
exit 0