[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Renaming categories in Gnats 3.113.1
From: |
Hans-Albert Schneider |
Subject: |
Re: Renaming categories in Gnats 3.113.1 |
Date: |
Tue, 22 Apr 2003 16:22:19 +0200 |
Walt Sullivan wrote:
>
> I'm running Gnats 3.113.1, GnatsWeb 2.9.3 on Linux.
> I've received a request to change the names of several categories.
I faced the same problem almost exactly two years ago.
There is now an entry in the GNATS FAQ about this. The FAQ is at
http://www.gnu.org/software/gnats/doc/faq/gnats-faq.html
Go to "Configuration Issues" / "General Configuration Questions" /
"How do I rename a category?"
If you want to check the mails from then, go to
http://mail.gnu.org/archive/html/help-gnats/
and search for
categor* and renam*
> Is it as simple as I think? I think I can:
>
> 1. Stop the queue-pr cron job.
>
> 2. Edit the "categories" file, change "oldname" to "newname".
>
> 3. Rename the directory from "oldname" to "newname".
>
> 4. Restart the queue-pr cron job.
>
> Is it really that simple, or are there gotchas waiting to bite me?
If you are using proper locking, steps 1 and 4 are superflouos.
If you do not use locking, steps 2 and 3 may interfere with somebody
else changing one of the reports at the same time.
As the PR files themselves bear the category name in them, steps 2
and 3 are not that simple: the index is not updated, and (at least
in GNATS 3.xxx) it contains the category names given in the file.
The FAQ describes a safer method. I use the attached script when I
have to rename a category. I have written similar scripts for changing
responsibles and e-mail addresses (which was necessary because our
team has been transfered to another company).
Note: I did not yet check whether this script also works for GNATS 4.0.
I am aware of one caveat with GNATS 4:
If you changed the the name of the "Category" field, you need to
adjust the strings in lines 45, 49, and 82.
Hans-Albert
--
Hans-Albert Schneider <address@hidden>
Infineon Technologies AG phone: (+49) 89 234 45445
Corporate Logic; Verification fax: (+49) 89 234 724399
(CL DAT TDM VM) Munich, Germany
#!/bin/sh
#
# Move a report from one category to another.
# Author: address@hidden
# Copyright (C) Siemens AG, CT SE 4, 2001
#
usage="usage: $0 -d gnats_root old_category new_category"
# Check usage
if [ $# -lt 4 ]
then
echo $usage >&2
exit 1
fi
if [ "x$1" = "x-d" ]
then
gnatsroot="$2"
else
echo $usage >&2
exit 1
fi
oldcat="$3"
newcat="$4"
if [ ! -d "$gnatsroot/$oldcat" ]
then
echo $usage >&2
exit 1
fi
if [ ! -d "$gnatsroot/$newcat" ]
then
mkcat -d "$gnatsroot"
fi
if [ ! -d "$gnatsroot/$newcat" ]
then
echo $usage >&2
exit 1
fi
echo "Category" | grep -i "$newcat" >/dev/null
if [ $? -eq 0 ]
then
echo "Sorry, but the name of the old category, $oldcat," >&2
echo "is a substring of the word 'Category'." >&2
echo "This script cannot deal with that case; it would mess up" >&2
echo "your reports." >&2
echo "Please do the renaming manually." >&2
exit 2
fi
#
# End of usage checking
#
# First, check for the trivial case:
reports=`echo "$gnatsroot/$oldcat"/*`
if [ "x$reports" = "x$gnatsroot/$oldcat/*" ]
then
echo "No entries in category $oldcat"
exit 0
fi
# 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}/mvcat$$
[ -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 category of GNATS problem report
EOF
echo "(echo '/>Category:/ s/$oldcat/$newcat/'; echo w) | ed "'$1' >> "$tmp"
EDITOR="$tmp"
export EDITOR
unset VISUAL
set -- "$gnatsroot/$oldcat"/*
for id in "$@"
do
edit-pr -d "$gnatsroot" `basename $id`
done
rm -f "$tmp"