maldito.orco Blogo

Friday, July 01, 2005

Verificando Mensajes de Log en CVS

Primero lo primero ... todo adminstrador de CVS deberia haber leido el apendice C del Cederqvist (Reference manual for Administrative files), si todavia no lo hisiste ... estas a tiempo.

Particularmente vamos a referirnos a la parte de Trigger Scripts, donde basicamente nos menciona varios archivos que funcionan como una especie de callback de los estados de un commit (Commit Support Files) , transcribo aca la def de estos callbacks:

"
There are three kinds of trigger scripts (see section The Trigger Scripts) that can be run at various times during a commit. They are specified in files in the repository, as described below. The following table summarizes the file names and the purpose of the corresponding programs.
`commitinfo'

The program is responsible for checking that the commit is allowed. If it exits with a non-zero exit status the commit will be aborted.

`verifymsg'

The specified program is used to evaluate the log message, and possibly verify that it contains all required fields. This is most useful in combination with the `rcsinfo' file, which can hold a log message template (see section Rcsinfo).

`editinfo'

The specified program is used to edit the log message, and possibly verify that it contains all required fields. This is most useful in combination with the `rcsinfo' file, which can hold a log message template (see section Rcsinfo). (obsolete)

`loginfo'

The specified program is called when the commit is complete. It receives the log message and some additional information and can store the log message in a file, or mail it to appropriate persons, or maybe post it to a local newsgroup, or… Your imagination is the limit!


"

Con esto podemos hacer cualquier cosa, ya que tenemos a nuestra disposicion interrumpir, modificar y permitir el commit a traves de la ejecucion de scripts (ejecutables, shell script, perl, o lo que soñemos).

Pese a que en estas referencias hay muy buenos ejemplos, les paso aca uno de lo mas sencillo que va a verificar si el log fue comitiado vacio y generar un error a aquellos desarrolladores que traten de hacer su trabajo de la forma simplista (osea comitiar con el log en banco)

Este es el contenido del archivo $CVSROOT/CVSROOT/verifymsg

DEFAULT /home/cvsadmin/cvssupport/validate-cvs-emptylog.sh


Este es el contenido del shell script validate-cvs-emptylog.sh

#!/bin/sh
#
# By maldito.orco
# validate-cvs-emptylog.sh logfile
#
# valida si el mensaje de log (aka $1) es menor a 10 caracteres

# test that log message has some characters in it
if [ `cat $1 | wc -c ` -lt 10 ] ; then
echo "log message too short; please enter a description for the changes"
exit 1
else
exit 0
fi

Este ejemplo fue sacado de CVS Best Practices el cual tambien es lectura obligada.

Espero que les sirva y si tienen dudas consulten a su CM de confianza.

PD: Esto es para los puberes de Toni_CM y Varmando_G