-
Notifications
You must be signed in to change notification settings - Fork 8
/
parse_log.sh
executable file
·95 lines (87 loc) · 2.71 KB
/
parse_log.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
#
usage(){
echo "Usage: $0 [options...] <tag1> <tag2>"
echo ""
echo "Use 'git log' to extract tracker IDs between two tags/commits."
echo ""
echo "Examples: $0 1.0-beta3 1.0-beta4"
echo " $0 1.0-beta3 HEAD"
echo "Options:"
echo " -f Filter only bug fixes (\"Fixes\") and features (\"Closes\")."
echo " Default is to show all tracker numbers (#id) that appear in git log output."
echo " -h Strip \# before numbers."
echo " -s Split bug fixes and features in two separate lists. Implies -f."
echo " -q Quiet: just list(s) of numbers (no text)."
echo " -a Sort IDs in ascending order (default is descending order)."
echo " -plain Generate plain text output rather than HTML (with links to Redmine)."
exit 1
}
if [ $# -lt 2 ] ; then
usage
fi
HASH=1
REVERT=r
SHOW_ALL=1
HTML=1
while [ "$1" ] ; do
case "$1" in
-f) SHOW_ALL="";;
-s) SPLIT=1;SHOW_ALL="";;
-h) HASH="";;
-q) QUIET=1;;
-a) REVERT="";;
-plain) HTML="";;
-html) HTML="1";; # Legacy option
*)
if [ -z "$TAG1" ] ; then
TAG1="$1"
else
if [ -z "$TAG2" ] ; then
TAG2="$1"
else
usage
fi
fi
;;
esac
shift
done
SPACE=" "
NL="\n"
[ "$HTML" ] && NL="<br>"
FIXED=`git log --pretty=oneline $TAG1..$TAG2 | grep -e '[Ff]ixe\?s\? *#' | sed 's/.*[Ff]ixe\?s\? *#\([0-9][0-9]*\).*/\1/' | sort -n$REVERT | uniq`
CLOSED=`git log --pretty=oneline $TAG1..$TAG2 | grep -e '[Cc]loses\? *#' | sed 's/.*[Cc]loses\? *#\([0-9][0-9]*\).*/\1/' | sort -n$REVERT | uniq`
FIXED_AND_CLOSED=`for i in $FIXED $CLOSED ; do echo $i ; done | sort -n$REVERT`
ALL=`git log --pretty=oneline $TAG1..$TAG2 | awk '{ split($0, array) ; for (item in array) { if (match($item, "#[0-9][0-9]+")) { print substr($item, RSTART+1, RLENGTH-1) } } }' | sort -n$REVERT | uniq`
print_ids() {
eval IDS='$'$1
for i in $IDS ; do
[ "$HTML" ] && printf "<a href=\"https://nano.taodyne.com/redmine/issues/$i\">"
[ "$HASH" ] && printf "#"
printf -- $i
[ "$HTML" ] && printf "</a>"
printf "$SPACE"
done
}
ALL=`print_ids ALL`
FIXED=`print_ids FIXED`
CLOSED=`print_ids CLOSED`
FIXED_AND_CLOSED=`print_ids FIXED_AND_CLOSED`
[ "$HTML" ] && echo "<html><body>"
[ "$QUIET" ] || printf "$TAG1 .. $TAG2$NL"
if [ "$SHOW_ALL" ] ; then
[ "$QUIET" ] || printf "All tracker IDs: "
printf "$ALL""$NL"
else
if [ "$SPLIT" ] ; then
[ "$QUIET" ] || printf "(Bugs) fixed: "
printf "$FIXED""$NL"
[ "$QUIET" ] || printf "(Feats) closed: "
printf "$CLOSED""$NL"
else
[ "$QUIET" ] || printf "Bugs and fetures: "
printf "$FIXED_AND_CLOSED""$NL"
fi
fi
[ "$HTML" ] && echo "</body></html>"