freebsd-ports/databases/gnats/files/gnats-edit-pr.patch

173 lines
5.1 KiB
Diff

--- gnats/gnats-edit-pr.sh.orig Tue Apr 20 23:17:07 1999
+++ gnats/gnats-edit-pr.sh Sat Jun 1 13:42:31 2002
@@ -124,15 +124,22 @@
*)
if [ "`echo $1 | grep /`" != "" ]; then
- pr_id=`echo $1 | awk -F"/" '{print $2}' -`
+ pr=`echo $1 | awk -F"/" '{print $2}' -`
else
- pr_id=$1
+ pr=$1
fi
+ prs="$prs $pr"
;;
esac
shift
done
+chng_tpl="/home/gnats/gnats-adm/edit-pr-msg"
+
+for pr_id in $prs ; do
+
+chng_msg="/tmp/chng.$pr.$$"
+
# set command here to always pass host and port, and directory if supplied
if [ "$mode" = "network" ]; then
prog="nedit-pr"
@@ -149,12 +156,12 @@
fi
# These traps take care of deleting all the /tmp files
-trap 'rm -f $new $new.old $change_msg ; exit 0' 0
+trap 'rm -f $new $new.old $change_msg $chng_msg; exit 0' 0
trap 'if [ "$locked" != "" ]; then \
$PR_EDIT --unlock $pr_id ; \
locked= ; \
fi ; \
- rm -f $new $new.old $change_msg ; exit 1' 1 2 3 13 15
+ rm -f $new $new.old $change_msg $chng_msg; exit 1' 1 2 3 13 15
# find a user name
if [ "$USER" != "" ]; then
@@ -192,7 +197,7 @@
if cmp -s $new.old $new ; then
echo "$prog: PR not changed"
$PR_EDIT --unlock $pr_id
- exit 0
+ continue
fi
# error-check output by calling pr-edit --check; if mistakes exist,
@@ -229,6 +234,8 @@
new_resp="`sed -n '/^>Responsible:/{s,^>[-a-zA-Z]*: *,,;s, *(.*,,g;p;q;}' $new`"
old_synopsis="`sed -n '/^>Synopsis:/{s,^>[-a-zA-Z]*: *,,;p;q;}' $new.old`"
new_synopsis="`sed -n '/^>Synopsis:/{s,^>[-a-zA-Z]*: *,,;p;q;}' $new`"
+old_class="`sed -n '/^>Class:/{s,^>[-a-zA-Z]*: *,,;p;q;}' $new.old`"
+new_class="`sed -n '/^>Class:/{s,^>[-a-zA-Z]*: *,,;p;q;}' $new`"
full_id="`sed -n '/^>Category:/{s,^>[-a-zA-Z]*: *,,;p;q;}' $new`/$pr_id"
# If you can read this, you may have a future in sed(1) programming.
@@ -256,8 +263,12 @@
if [ "$old_resp" != "$new_resp" ]; then
resp_change=yes
fi
+if [ "$old_class" != "$new_class" ]; then
+ class_change=yes
+fi
-if [ ! -z "$state_change" ] || [ ! -z "$resp_change" ]; then
+if [ ! -z "$state_change" ] || [ ! -z "$resp_change" ] || \
+ [ ! -z "$class_change" ]; then
# we've got a change
mail_to="$me"
if [ ! -z "$state_change" ]; then
@@ -266,14 +277,47 @@
echo State-Changed-By: $me >> $change_msg
echo State-Changed-When: $DATE >> $change_msg
echo "State-Changed-Why: " >> $change_msg
- echo 'Why did the state change? (Ctrl-D to end)'
- cat >> $change_msg
+ if [ -e $chng_msg ]; then
+ echo "Re-use last message (y/n)?"
+ read yesno
+ if [ "$yesno" != "y" ]; then
+ sed 's/%%ITEM%%/state/' $chng_tpl > $chng_msg
+ fi
+ else
+ sed 's/%%ITEM%%/state/' $chng_tpl > $chng_msg
+ fi
+ $VISUAL $chng_msg
+ sed '/^GNATS:/d' $chng_msg >> $change_msg
to_old=1
to_subm=1
+ if [ ! -z "$class_change" ] || [ ! -z "$resp_change" ]; then
+ echo "" >> $change_msg
+ echo "" >> $change_msg
+ fi
fi
- if [ ! -z "$state_change" ] && [ ! -z "$resp_change" ]; then
- echo "" >> $change_msg
- echo "" >> $change_msg
+ if [ ! -z "$class_change" ]; then
+ $debug_print "Doing class change."
+ echo Class-Changed-From-To: "$old_class"'->'"$new_class" >> $change_msg
+ echo Class-Changed-By: $me >> $change_msg
+ echo Class-Changed-When: $DATE >> $change_msg
+ echo "Class-Changed-Why: " >> $change_msg
+ if [ -e $chng_msg ]; then
+ echo "Re-use last message (y/n)?"
+ read yesno
+ if [ "$yesno" != "y" ]; then
+ sed 's/%%ITEM%%/class/' $chng_tpl > $chng_msg
+ fi
+ else
+ sed 's/%%ITEM%%/class/' $chng_tpl > $chng_msg
+ fi
+ $VISUAL $chng_msg
+ sed '/^GNATS:/d' $chng_msg >> $change_msg
+ to_old=1
+ to_new=1
+ if [ ! -z "$resp_change" ]; then
+ echo "" >> $change_msg
+ echo "" >> $change_msg
+ fi
fi
if [ ! -z "$resp_change" ]; then
$debug_print "Doing responsible change."
@@ -281,12 +325,24 @@
echo Responsible-Changed-By: $me >> $change_msg
echo Responsible-Changed-When: $DATE >> $change_msg
echo "Responsible-Changed-Why: " >> $change_msg
- echo 'Why did the responsible person change? (Ctrl-D to end)'
- cat >> $change_msg
+ if [ -e $chng_msg ]; then
+ echo "Re-use last message (y/n)?"
+ read yesno
+ if [ "$yesno" != "y" ]; then
+ sed 's/%%ITEM%%/responsible/' $chng_tpl > $chng_msg
+ fi
+ else
+ sed 's/%%ITEM%%/responsible/' $chng_tpl > $chng_msg
+ fi
+ $VISUAL $chng_msg
+ sed '/^GNATS:/d' $chng_msg >> $change_msg
to_old=1
to_new=1
fi
+ echo "" >> $change_msg
+ echo "http://www.freebsd.org/cgi/query-pr.cgi?pr=$pr_id" >> $change_msg
+
if [ -n "$to_subm" ]; then mail_to="${reply_to}, ${mail_to}" ; fi
if [ -n "$x_gnats_notify" ]; then mail_to="${x_gnats_notify}, ${mail_to}" ; fi
if [ -n "$to_old" ] ; then mail_to="${mail_to}, `$PR_ADDR ${old_resp}`" ; fi
@@ -303,7 +359,7 @@
$MAIL_AGENT << __EOF__
To: $mail_to
From: $me
-Subject: Re: $full_id
+Subject: Re: $full_id: $new_synopsis
`if [ "$old_synopsis" != "$new_synopsis" ]; then
echo Old Synopsis: "$old_synopsis"
@@ -321,5 +377,9 @@
# call PR_EDIT on the new file and clean up
$PR_EDIT < $new
$PR_EDIT --unlock $pr_id
+
+rm -f $chng_msg
+
+done
exit 0