Newer
Older
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
# diffatt.sh - generate inspection template for attachment
if [ -z "$1" ]; then
cat - 1>&2 <<- USAGE
usage: $0 [-k] {attachment} [attachment ...]
-k: keep attachment(s) for editing (delete otherwise)
attachment is an attachment number or a local patch filename
USAGE
exit 1
fi
export LANG=C
BUGZILLA=https://bugzilla.lustre.org/attachment.cgi
TMP=${TMP:-/tmp}
[ "$1" = "-k" ] && KEEP=yes && shift
FILE=$(mktemp -t)
for ATT in $*; do
DO_KEEP=$KEEP
if [ -f "$ATT" ]; then
PATCH=$ATT
BUG=N
DO_KEEP=yes
else
BUG=$(wget --no-check-certificate -O - \
$BUGZILLA?id=$ATT\&action=edit 2> /dev/null |
perl -nle 'print $1 if /Details for Bug (\d+)/' -)
PATCH=$TMP/att$ATT.patch
wget --no-check-certificate -O $PATCH \
$BUGZILLA?id=$ATT 2> /dev/null
fi
grep "not authorized" $PATCH && continue
diffstat $PATCH | tee $FILE
LOC=$(awk '/insertion/ { print $4 }' $FILE)
[ -z "$LOC" ] && LOC=$(awk '/deletion/ { print $4 }' $FILE)
# if it isn't a patch, just count all of the lines
[ -z "$LOC" ] && $(grep -q "0 files changed" $FILE) &&
LOC=$(cat $PATCH | wc -l)
tee -a $PATCH <<- EOF
Inspection Type: CODE
Defect Count: N
Size: $LOC LOC
Developer: @sun.com
Inspector: $USER@sun.com
Inspection duration: N min
Bug: $BUG
Date: $(date +%Y-%m-%d)
EOF
[ "$DO_KEEP" = "yes" ] || rm $PATCH
done