2 # diffatt.sh - generate inspection template for attachment
5 usage: $0 [-k] {attachment} [attachment ...]
6 -k: keep attachment(s) for editing (delete otherwise)
7 attachment is an attachment number or a local patch filename
13 BUGZILLA=https://bugzilla.lustre.org/attachment.cgi
16 [ "$1" = "-k" ] && KEEP=yes && shift
22 if [ -f "$ATT" ]; then
27 BUG=$(wget --no-check-certificate -O - \
28 $BUGZILLA?id=$ATT\&action=edit 2> /dev/null |
29 perl -nle 'print $1 if /Details for Bug (\d+)/' -)
30 PATCH=$TMP/att$ATT.patch
31 wget --no-check-certificate -O $PATCH \
32 $BUGZILLA?id=$ATT 2> /dev/null
35 grep "not authorized" $PATCH && continue
37 diffstat $PATCH | tee $FILE
38 LOC=$(awk '/insertion/ { print $4 }' $FILE)
39 [ -z "$LOC" ] && LOC=$(awk '/deletion/ { print $4 }' $FILE)
41 # if it isn't a patch, just count all of the lines
42 [ -z "$LOC" ] && $(grep -q "0 files changed" $FILE) &&
43 LOC=$(cat $PATCH | wc -l)
50 Inspector: $USER@sun.com
51 Inspection duration: N min
53 Date: $(date +%Y-%m-%d)
56 [ "$DO_KEEP" = "yes" ] || rm $PATCH