[cvsnt] Can CVS require a check in comment?

Gabriel Genellina gagsl-cvsnt at yahoo.com.ar
Wed Jun 27 04:01:35 BST 2007


Community technical support mailing list was retired 2010 and replaced with a professional technical support team. For assistance please contact: Pre-sales Technical support via email to sales@march-hare.com.


En Tue, 26 Jun 2007 18:07:30 -0300, Gerhard Fiedler  
<lists at connectionbrazil.com> escribió:

> Added to the wiki at <http://www.cvsnt.org/wiki/ForceCommitComment> and
> <http://tinyurl.com/2ay9e6>.

Here you have the same validation but using a Python script, that may be  
easier to customize. (Any server with viewvc/viewcvs installed already has  
Python)

The corresponding verifymsg line should read:

DEFAULT /path/to/python path/to/verifymsg.py

--- begin verifymsg.py ---
#!/usr/bin/env python

"""Enforce some minimum restrictions on commit messages"""

# compatible with any Python version 2.1 and up

import sys

class Error(Exception): pass
class AbnormalError(Error): pass

def process(filename):
     # read message from file
     try:
         f = open(filename, "r")
         try:
             msg = f.read()
         finally:
             f.close()
     except:
         raise AbnormalError, "can't read commit message. %s: %s" %  
sys.exc_info()[:2]

     # ignore leading and trailing whitespace
     msg = msg.strip()

     # at least two words separated by any whitespace
     words = msg.split()
     if len(words)<2:
         raise Error, "Commit messages must be more meaningful."

     # at least 6 chars, not counting whitespace nor linefeeds and such
     nonws = reduce(lambda sum,word: sum+len(word), words, 0)
     if nonws<6:
         raise Error, "Commit messages must be more meaningful."

     # 0 means OK
     return 0

def main(argv):
     try:
         if len(argv)<2:
             raise AbnormalError, "missing argument: filename"
         return process(argv[1])
     except Error,e:
         print "%s: %s" % (e.__class__.__name__, " ".join(e.args))
         return 1
     except:
         print "%s: %s" % sys.exc_info()[:2]
         return 1

if __name__=='__main__':
     sys.exit(main(sys.argv))

--- end verifymsg.py ---

-- 
Gabriel Genellina


More information about the cvsnt mailing list
Download the latest CVSNT, TortosieCVS, WinCVS etc. for Windows 8 etc.
@CVSNT on Twitter   CVSNT on Facebook