Verifying

Once you have entered a log message, you can evaluate that message to check for specific content, such as a bug ID. Use the verifymsg file to specify a program that is used to verify the log message. This program could be a simple script that checks that the entered message contains the required fields.

The verifymsg file is often most useful together with the rcsinfo file, which can be used to specify a log message template.

Each line in the verifymsg file consists of a regular expression and a command-line template. Each line can have any combination of the following, in addition to those listed in the common syntax.

%p

Directory name relative to the current root.

%l

Full path to file containing the log message.

The template must include a program name, and can include any number of arguments. If no other formatting is used %l is automatically added which appends the full path to the current log message file file to the template.

If the repository name does not match any of the regular expressions in this file, the DEFAULT line is used, if it is specified.

If the verification script exits with a non-zero exit status, the commit is aborted.

Note that the verification script cannot change the log message; it can merely accept it or reject it.

The following is a little silly example of a verifymsg file, together with the corresponding rcsinfo file, the log message template and an verification script. We begin with the log message template. We want to always record a bug-id number on the first line of the log message. The rest of log message is free text. The following template is found in the file /usr/cvssupport/tc.template.

BugId:

The script /usr/cvssupport/bugid.verify is used to evaluate the log message.

#!/bin/sh
#
#       bugid.verify filename
#
#  Verify that the log message contains a valid bugid
#  on the first line.
#
if head -1 < $1 | grep '^BugId:[ ]*[0-9][0-9]*$' > /dev/null; then
    exit 0
else
    echo "No BugId found."
    exit 1
fi

The verifymsg file contains this line:

^tc     /usr/cvssupport/bugid.verify

The rcsinfo file contains this line:

^tc     /usr/cvssupport/tc.template