public inbox for gnats-devel@sourceware.org
 help / color / mirror / Atom feed
* Mass edit-pr
@ 2004-03-26 17:46 Adam Cade
  2004-03-27  9:58 ` Hans-Albert Schneider
  0 siblings, 1 reply; 2+ messages in thread
From: Adam Cade @ 2004-03-26 17:46 UTC (permalink / raw)
  To: help-gnats

Is there any way to do a mass edit on the pr's??

(Editing the same field within a number of pr's)

Thanks.
Adam

-- 
Adam Cade , Go Internet Ltd
email: adam@gointernet.co.uk
voice: +44 (0)20 7419 0001
fax  : +44 (0)20 7419 6519
web  : www.gointernet.co.uk




_______________________________________________
Help-gnats mailing list
Help-gnats@gnu.org
http://mail.gnu.org/mailman/listinfo/help-gnats

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Mass edit-pr
  2004-03-26 17:46 Mass edit-pr Adam Cade
@ 2004-03-27  9:58 ` Hans-Albert Schneider
  0 siblings, 0 replies; 2+ messages in thread
From: Hans-Albert Schneider @ 2004-03-27  9:58 UTC (permalink / raw)
  To: Adam Cade; +Cc: help-gnats

[-- Attachment #1: Type: text/plain, Size: 1225 bytes --]

Adam Cade wrote:
> Is there any way to do a mass edit on the pr's??
> 
> (Editing the same field within a number of pr's)

Yes.  I wrote the attached script to change the Responsible: field of 
reports after a colleague left.

It does a lot of checking on files and also on its arguments, but the 
trick is to create a little temporary file that does the replacement 
(using the UNIX editor "ed"), have $EDITOR point to it, and then call 
edit-pr for each report.

(I used this idea for other purposes, too.  E.g., when we were shifted 
from Siemens to Infineon I needed to adjust all our mail addresses, and 
I used the opportunity to also cleanup the X-GNATS-NOTIFY: lines from 
obsolete addresses.)


Note that this still stems from the GNATS 3.11x times; the line
	pr_list=`awk ...`
will not work with GNATS 4 (the index file is now a binary format).  The 
line extracts those reports that belong to the old responsible and are 
not closed.

But I think this should get you started.


Have a nice weekend,

Hans-Albert
-- 
Hans-Albert Schneider		<Hans-Albert.Schneider@infineon.com>
Infineon Technologies AG	phone:	(+49) 89 234 45445
Corporate Logic; Verification	fax:	(+49) 89 234 724399
(CL DAT DF V)			Munich, Germany

[-- Attachment #2: change_responsible --]
[-- Type: text/plain, Size: 2397 bytes --]

#!/bin/sh
#
# change the >Responsible: of all non-closed reports.
# Author: Hans-Albert.Schneider@mchp.siemens.de
# Copyright (C) Infineon Technologies AG, 2002
#

usage="usage: $0 -d gnats_root old_responsible new_responsible reason"

# Check usage
if [ $# -lt 5 ]
then
    echo $usage >&2
    exit 1
fi

if [ "x$1" = "x-d" ]
then
    if [ "x$2" = "x" ]
    then
	echo $usage >&2
	exit 1
    else
	gnatsroot="$2"
    fi
else
    echo $usage >&2
    exit 1
fi

if [ "x$3" = "x" -o  "x$4" = "x"  -o  "x$5" = "x" ]
then
    echo $usage >&2
    exit 1
fi

oldresp="$3"
newresp="$4"
reason="$5"


if [ ! -f "$gnatsroot/gnats-adm/index" ]
then
    echo $usage >&2
    echo "Cannot find index file $gnatsroot/gnats-adm/index" >&2
    exit 1
fi


resp_file=$gnatsroot/gnats-adm/responsible

if grep "^${oldresp}:" "$resp_file"
then
    : OK
else
    echo "Warning: '${oldresp}' not listed in $resp_file" >&2
    # No exit here; we are going to replace her/him anyway.
fi

if grep "^${newresp}:" "$resp_file"
then
    : OK
else
    echo $usage >&2
    echo "Warning: New responsible '${newresp}' not listed in $resp_file" >&2
    exit 1
fi


pr_list=`awk '-F|' '$3 == resp && $4 != "closed" {print $1}' resp="${oldresp}" $gnatsroot/gnats-adm/index`

if [ "x$pr_list" = "x" ]
then
    echo "No reports for '${oldresp}' found."
    exit 0
fi


echo "Responsible" | grep -i "${oldresp}" >/dev/null
if [ $? -eq 0 ]
then
    echo "Sorry, but the name of the new responsible, '${newresp}'," >&2
    echo "is a substring of the word 'Responsible'." >&2
    echo "This script cannot deal with that case; it would mess up" >&2
    echo "your reports." >&2
    echo "Please do the assignment manually." >&2
    exit 2
fi

#
# End of usage checking
#

# Create a temporary file to be used as the EDITOR environment variable.
# Make sure it belongs to us, and nobody else can modify it.
#
tmp=${TMPDIR:-/tmp}/chresp$$
[ -f "$tmp" ] && rm -f "$tmp"
[ -f "$tmp" ] && echo "Cannot rm $tmp" >&2 && exit 2
touch "$tmp" || echo "Cannot create $tmp" >&2
[ -f "$tmp" ] || exit 2
chmod 700 "$tmp"

cat >"$tmp" <<EOF
#!/bin/sh
# change responsible of GNATS problem report
EOF
echo "(echo '/>Responsible:/ s/${oldresp}/${newresp}/'; echo w) | ed "'$1' >> "$tmp"

EDITOR="$tmp"
export EDITOR
unset VISUAL


for id in $pr_list
do
    echo "Changing PR# $id ..."
    echo "$reason" | edit-pr -d "$gnatsroot" $id
done

rm -f "$tmp"

[-- Attachment #3: Type: text/plain, Size: 139 bytes --]

_______________________________________________
Help-gnats mailing list
Help-gnats@gnu.org
http://mail.gnu.org/mailman/listinfo/help-gnats

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-03-26 17:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-26 17:46 Mass edit-pr Adam Cade
2004-03-27  9:58 ` Hans-Albert Schneider

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).