info-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: commitinfo


From: Mark D. Baushke
Subject: Re: commitinfo
Date: Fri, 09 Sep 2005 18:10:20 -0700

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

juice jj <address@hidden> writes:

> How can I get the content of the file being checked in in a commitinfo
> script. I saw variables to get the file name (%{s}) etc but did not
> see anything to access the content of the file.

The filename is passed to the script. Feel free to open the filename.
You will find it in the local directory.

Here is an example to help you see how things could work...

if [ -d /tmp/test-repos -o -d /tmp/CVSROOT ]; then
  echo test not run as /tmp/test-repos and/or /tmp/CVSROOT already exist.
else
cd /tmp
cvs -d /tmp/test-repos init
cvs -d /tmp/test-repos checkout CVSROOT
cd CVSROOT
cat <<"EOF" >> commitinfo
ALL $CVSROOT/CVSROOT/disallow-bad-symbol MYSYMBOL %{s}
EOF
cat <<"EOF" > disallow-bad-symbol
#! /bin/sh
# Do not allow commits with the symbol given as the first argument
# to this script to be in any of committed files.
bad=$1
shift
rc=0
for file in $*; do
  if grep $bad $file > /dev/null 2>&1 ; then
    echo "Found bad symbol '$bad' in '$file'" 1>&2
    rc=1
  fi
done
if [ $rc -eq 1 ]; then
    echo Your commit will be disallowed 1>&2
fi
exit $rc
EOF
chmod +x disallow-bad-symbol
echo disallow-bad-symbol >> checkoutlist
cvs add disallow-bad-symbol
cvs commit -madd-sentinel checkoutlist commitinfo disallow-bad-symbol
: test it now
echo MYSYMBOL > bar
cvs add bar
cvs commit -mtestit bar && echo this test failed || echo this test passed
echo this version of bar is okay. > bar
cvs commit -mtestit bar && echo this test passed || echo this test failed
fi

        Enjoy!
        -- Mark
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (FreeBSD)

iD8DBQFDIjJ8Cg7APGsDnFERAu9QAKC3hrrm3xa+SIOhR1P8EIXUpQvxFwCfW+2P
AwbF0vyF1/j7tANepKJFPnw=
=aQpw
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]