From: Hans-Albert Schneider <Hans-Albert.Schneider@infineon.com>
To: Adam Cade <adam@gointernet.co.uk>
Cc: help-gnats@gnu.org
Subject: Re: Mass edit-pr
Date: Sat, 27 Mar 2004 09:58:00 -0000 [thread overview]
Message-ID: <40646998.1030709@infineon.com> (raw)
In-Reply-To: <40642E4E.7090509@gointernet.co.uk>
[-- 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
prev parent reply other threads:[~2004-03-26 17:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-26 17:46 Adam Cade
2004-03-27 9:58 ` Hans-Albert Schneider [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=40646998.1030709@infineon.com \
--to=hans-albert.schneider@infineon.com \
--cc=adam@gointernet.co.uk \
--cc=help-gnats@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).