[Zope3-dev] Denying commit for carriage returns in text
Jim Fulton
jim@zope.com
Wed, 13 Nov 2002 17:50:38 -0500
Fred L. Drake, Jr. wrote:
> I've attached a script that could be run from CVSROOT/commitinfo that
> denies a commit if a text file contains a carriage return. It ignores
> binary files (the -kb sticky option is set).
Cool. Thanks. What do people think about puting this in place?
Jim
>
> -Fred
>
>
>
> ------------------------------------------------------------------------
>
> #! /bin/sh
> REPODIR="$1"
> shift
>
> TEMPFILE="/tmp/check-commit-$$"
> for FILE in "$@" ; do
> REPOFILE="$REPODIR/$FILE,v"
> if test -f "$REPOFILE" -a -f "$FILE" ; then
> if (rlog -h "$REPOFILE" \
> | grep 'keyword substitution:' \
> | sed 's/^.*: //' \
> | grep -q b); then
> echo >/dev/null
> else
> sed "s/`echo -en '\r'`//" "$FILE" >"$TEMPFILE"
> cmp "$FILE" "$TEMPFILE"
> RC=$?
> rm -f "$TEMPFILE"
> if test $RC -ne 0 ; then
> echo '***'
> echo '*** Found carriage returns in text file; commit denied!'
> echo '***'
> exit $RC
> fi
> fi
> fi
> done
>
> exit 0
>
--
Jim Fulton mailto:jim@zope.com Python Powered!
CTO (888) 344-4332 http://www.python.org
Zope Corporation http://www.zope.com http://www.zope.org