[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: cvs remove and pre-commit check
From: |
Mark E. Hamilton |
Subject: |
Re: cvs remove and pre-commit check |
Date: |
Wed, 16 Nov 2005 14:09:39 -0700 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20040913 |
Lakshman Srilakshmanan wrote:
Hi All,
I'm presuming that you are using 1.11.x. The following may apply to
1.12.x, but I don't know.
First, read this:
http://ximbiot.com/cvs/manual/cvs-1.11.21/cvs_18.html#SEC171
I have a pre-commit check as follows. It checks to ensure that the cvs
tags Author, Revision and Header are present in the file.
No, it doesn't
#!/bin/sh
filename=$*
dirName=$2
Author=`grep '\$Author' $filename`
if [ -z "$Author" ] ; then
echo "Author does not Exists"
exit 1
fi
<irrelevant commands removed from sample script>
This isn't going to work. According the man page, the parameters passed
to the command invoked by commitinfo are any parameters you put on the
command line, followed by the repository directory and *all* the file
names. Assuming you don't pass any other parameters to your script from
your commitinfo file, your script's parameters will be
dir f1 {f2 ...}
So, what you should be doing is something like this:
#!/bin/sh
dirName=$1
shift
for filename in $*
do
check file $filename
done
It works fine for new files and changes. But when I commit after a "cvs
remove" I get the following error
grep: sgs13.txt: No such file or directory
I understand, that since the file does not exist, grep can't find it.
But $* contains the following.
/cvs/sgs/src/conf sgs13.txt Note : /cvs ==> is my "cvs
server root".
Therefore non of my greps should have worked as the file will be called
sgs13.txt,v under /cvs and
would not exist under the repository anyway (for new files).
Your $filename variable value is incorrect. As you point out $* contains
*the directory and the file name(s)*, so that's what is in $filename.
So, your grep looks like this:
grep '\$Author' /cvs/sgs/src/conf sgs13.txt
This will fail to find $Author in the directory (obviously) but it may
find it in sgs13.txt, and so assign it to the variable.
For removed files, according to the manual when a file is being removed
it will not exist in the current directory. So, you can't grep it. You
should test it for existance before grep'ing it.
Also, since there will be more than one file on the command line you
must have a file loop as I said above. So combining the file loop and an
existance test you would need:
#!/bin/sh
dirName=$1
shift
for filename in $*
do
test ! -e $filename && continue
egrep >/dev/null 2>&1 'blah' $filename || { echo "message" ; exit 1 ; }
...
done
Q1. how does cvs know about my file when I am working from windows
client and the cvs server in on Linux.
Q2. Why does it work for new files when the directory is /cvs. New files
will not exist in the repository
New and modified files are copied to a temp directory on the server.
With a local repository they exist in your working directory.
Removed files are not copied to the server, and they do not exist in
your working directory.
http://ximbiot.com/cvs/manual/cvs-1.11.21/cvs_2.html#SEC26
Q3. Any workaround ?
You need to correct your script.
--
----------------
Mark E. Hamilton
Orion International Technologies, Inc.
Sandia National Laboratory, NM.
505-844-7666