Short program to dis-allow CVS commits if no comment is supplied
Y2KYZFR1
jarrodhroberson at yahoo.com
Fri Mar 12 01:05:26 EST 2004
Granted this only stopps the "forgetfull".
I tested it against the following clients, all of which supply a
DIFFERENT "no message" string.
WinCVS 1.3.14.1 Beta 14 ( Build 1 )
TortioseCVS
some MacClient
Eclipse 3.0 ( cvs built in client )
add this file to $CVSROOT/CVSROOT/checkoutlist
then add
.* $CVSROOT/CVSROOT/CVSRequireComment.py
to $CVSROOT/CVSROOT/verifymsg
# Filename = CVSRequireComment.py
#!/usr/bin/env python
import sys
def main():
# // args[0] is script name
# // args[1] is temp file name
# // stdin contains long log message from cvs
# // these are for debugging what is actually being suppiled
# // to this script
#sys.stderr.write( 'sript name = ' + sys.argv[0] + '\n' )
#sys.stderr.write( 'message temp file = ' + sys.argv[1] + '\n' )
#sys.stderr.write( 'stdin = "' + sys.stdin.read() +
'"\n' )
try:
logString = open( sys.argv[1] ).read()
logString = logString.strip()
#sys.stderr.write( 'logString = "' + logString + '"' )
except:
sys.stderr.write('No log message file found')
# // don't allow commits to files of the following type
if logString.find( '.class'):
sys.stderr.write( '.class files are not allowed in the
repository' )
sys.exit(1);
# // this is what WinCVS sends in when no message is supplied
# // version 1.3.14.1 Beta 14 Build 1 actually sends in 'no
message\n'
# // so I decided to do startswith() to handle the case if the \n
gets removed
# // eclipse's integrated cvs support uses '*** empty log message
**'
# // so again I use startswith() to detect those
# // tortoise just sends in a carrige return or line feed or
something
# // that is what the logString.strip() is for above
if ( logString.startswith( 'no message' ) ) or (
logString.startswith( '***' ) ) or ( not logString ) or ( len(
logString ) == 0 ):
sys.stderr.write('No comment was suppiled\n')
sys.stderr.write('You must supply a ** useful ** comment!\n' )
sys.stderr.write('A concise explaination of what was done or a
bug id is ok\n')
sys.exit(1)
else:
#sys.stderr.write( 'Thanks for supplying a comment' )
#sys.stderr.write('Comment == "' + logString + '"\n')
sys.exit(0)
if __name__ == "__main__":
main()
More information about the Python-list
mailing list