From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15984 invoked from network); 26 Mar 2004 17:46:47 -0000 Received: from unknown (HELO monty-python.gnu.org) (199.232.76.173) by sources.redhat.com with SMTP; 26 Mar 2004 17:46:47 -0000 Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.30) id 1B6vPO-0000iY-87 for listarch-gnats-devel@sources.redhat.com; Fri, 26 Mar 2004 12:46:18 -0500 Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.30) id 1B6vKL-0007F0-Sk for help-gnats@gnu.org; Fri, 26 Mar 2004 12:41:05 -0500 Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.30) id 1B6vJe-0006yQ-Rk for help-gnats@gnu.org; Fri, 26 Mar 2004 12:40:53 -0500 Received: from [194.175.117.76] (helo=smtp1.infineon.com) by monty-python.gnu.org with esmtp (Exim 4.30) id 1B6vDx-00056s-Ix for help-gnats@gnu.org; Fri, 26 Mar 2004 12:34:29 -0500 Received: from sonja.muc.infineon.com (mbox.ifx-mail2.com [172.31.97.182]) by smtp1.infineon.com (8.12.10/8.12.10) with ESMTP id i2QHT7CY015851; Fri, 26 Mar 2004 18:29:07 +0100 (MET) Received: from mail-g.muc.infineon.com (mail-g.muc.infineon.com [172.29.175.37]) by sonja.muc.infineon.com (8.12.11/8.12.9) with ESMTP id i2QHYKZN003408; Fri, 26 Mar 2004 18:34:21 +0100 (MET) Received: from infineon.com (klein [172.29.175.74]) by mail-g.muc.infineon.com with ESMTP id i2QHYGTj004344; Fri, 26 Mar 2004 18:34:17 +0100 (MET) Message-ID: <40646998.1030709@infineon.com> Date: Sat, 27 Mar 2004 09:58:00 -0000 From: Hans-Albert Schneider Organization: Infineon Technologies AG, CL DAT TDM VM User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030703 X-Accept-Language: en, German, de MIME-Version: 1.0 To: Adam Cade References: <40642E4E.7090509@gointernet.co.uk> In-Reply-To: <40642E4E.7090509@gointernet.co.uk> Content-Type: multipart/mixed; boundary="------------070804090600030706050901" Cc: help-gnats@gnu.org Subject: Re: Mass edit-pr X-BeenThere: help-gnats@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: General discussion about GNU GNATS List-Archive: List-Post: List-Help: List-Subscribe: , Sender: help-gnats-bounces+listarch-gnats-devel=sources.redhat.com@gnu.org Errors-To: help-gnats-bounces+listarch-gnats-devel=sources.redhat.com@gnu.org X-SW-Source: 2004-q1/txt/msg00177.txt.bz2 This is a multi-part message in MIME format. --------------070804090600030706050901 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1225 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 Infineon Technologies AG phone: (+49) 89 234 45445 Corporate Logic; Verification fax: (+49) 89 234 724399 (CL DAT DF V) Munich, Germany --------------070804090600030706050901 Content-Type: text/plain; name="change_responsible" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="change_responsible" Content-length: 2397 #!/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" <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" --------------070804090600030706050901 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline Content-length: 139 _______________________________________________ Help-gnats mailing list Help-gnats@gnu.org http://mail.gnu.org/mailman/listinfo/help-gnats --------------070804090600030706050901--