<div id="verifymsg"></div>
<div class="header">
<p>
Next: [[cvs: Editinfo#Editinfo|editinfo]], Previous: [[cvs: Commitinfo#Commitinfo|commitinfo]], Up: [[cvs: The commit support files#The commit support files|commit files]] &nbsp; |[[cvs: Index#SEC_Contents|Contents]]||[[cvs: Index#Index|Index]]|</p>
</div>

----

<div id="Verifying-log-messages"></div>
==== Verifying log messages ====
<div id="index-verifymsg-_0028admin-file_0029"></div>
<div id="index-Log-message_002c-verifying"></div>

Once you have entered a log message, you can evaluate
that message to check for specific content, such as
a bug ID.  Use the &lsquo;<tt>verifymsg</tt>&rsquo; 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 &lsquo;<tt>verifymsg</tt>&rsquo; file is often most useful together
with the &lsquo;<tt>rcsinfo</tt>&rsquo; file, which can be used to
specify a log message template.

Each line in the &lsquo;<tt>verifymsg</tt>&rsquo; file consists of a
regular expression and a command-line template.  The
template must include a program name, and can include
any number of arguments.  The full path to the current
log message template file is appended to the template.

One thing that should be noted is that the &lsquo;<code>ALL</code>&rsquo;
keyword is not supported.  If more than one matching
line is found, the first one is used.  This can be
useful for specifying a default verification script in a
directory, and then overriding it in a subdirectory.

<div id="index-DEFAULT-in-verifymsg"></div>
If the repository name does not match any of the
regular expressions in this file, the &lsquo;<code>DEFAULT</code>&rsquo;
line is used, if it is specified.

<div id="index-Exit-status_002c-of-verifymsg"></div>
If the verification script exits with a non-zero exit status,
the commit is aborted.

<div id="index-verifymsg_002c-changing-the-log-message"></div>
In the default configuration, CVS allows the
verification script to change the log message. This is
controlled via the RereadLogAfterVerify CVSROOT/config
option.

When &lsquo;<code>RereadLogAfterVerify=always</code>&rsquo; or
&lsquo;<code>RereadLogAfterVerify=stat</code>&rsquo;, the log message will
either always be reread after the verification script
is run or reread only if the log message file status
has changed.

See [[cvs: The CVSROOT%47config configuration file#The CVSROOT/config configuration file|config]], for more on CVSROOT/config options.

It is NOT a good idea for a &lsquo;<tt>verifymsg</tt>&rsquo; script to
interact directly with the user in the various
client/server methods. For the <code>pserver</code> method,
there is no protocol support for communicating between
&lsquo;<tt>verifymsg</tt>&rsquo; and the client on the remote end. For the
<code>ext</code> and <code>server</code> methods, it is possible
for CVS to become confused by the characters going
along the same channel as the CVS protocol
messages. See [[cvs: Remote repositories#Remote repositories|Remote repositories]], for more
information on client/server setups.  In addition, at the time
the &lsquo;<tt>verifymsg</tt>&rsquo; script runs, the CVS
server has locks in place in the repository.  If control is
returned to the user here then other users may be stuck waiting
for access to the repository.

This option can be useful if you find yourself using an
rcstemplate that needs to be modified to remove empty
elements or to fill in default values.  It can also be
useful if the rcstemplate has changed in the repository
and the CVS/Template was not updated, but is able to be
adapted to the new format by the verification script
that is run by &lsquo;<tt>verifymsg</tt>&rsquo;.

An example of an update might be to change all
occurrences of &rsquo;BugId:&rsquo; to be &rsquo;DefectId:&rsquo; (which can be
useful if the rcstemplate has recently been changed and
there are still checked-out user trees with cached
copies in the CVS/Template file of the older version).

Another example of an update might be to delete a line
that contains &rsquo;BugID: none&rsquo; from the log message after
validation of that value as being allowed is made.

The following is a little silly example of a
&lsquo;<tt>verifymsg</tt>&rsquo; file, together with the corresponding
&lsquo;<tt>rcsinfo</tt>&rsquo; 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
&lsquo;<tt>/usr/cvssupport/tc.template</tt>&rsquo;.

<div class="example" style="margin-left: 3.2em">
 BugId:
</div>

The script &lsquo;<tt>/usr/cvssupport/bugid.verify</tt>&rsquo; is used to
evaluate the log message.

<div class="example" style="margin-left: 3.2em">
 #!/bin/sh
 #
 #       bugid.verify filename
 #
 #  Verify that the log message contains a valid bugid
 #  on the first line.
 #
 if head -1 &lt; $1 | grep '^BugId:<nowiki>[</nowiki> <nowiki>]</nowiki>*<nowiki>[</nowiki>0-9<nowiki>][</nowiki>0-9<nowiki>]</nowiki>*$' &gt; /dev/null; then
     exit 0
 elif head -1 &lt; $1 | grep '^BugId:<nowiki>[</nowiki> <nowiki>]</nowiki>*none$' &gt; /dev/null; then
     # It is okay to allow commits with 'BugId: none',
     # but do not put that text into the real log message.
     grep -v '^BugId:<nowiki>[</nowiki> <nowiki>]</nowiki>*none$' &gt; $1.rewrite
     mv $1.rewrite $1
     exit 0
 else
     echo &quot;No BugId found.&quot;
     exit 1
 fi
</div>

The &lsquo;<tt>verifymsg</tt>&rsquo; file contains this line:

<div class="example" style="margin-left: 3.2em">
 ^tc     /usr/cvssupport/bugid.verify
</div>

The &lsquo;<tt>rcsinfo</tt>&rsquo; file contains this line:

<div class="example" style="margin-left: 3.2em">
 ^tc     /usr/cvssupport/tc.template
</div>

The &lsquo;<tt>config</tt>&rsquo; file contains this line:

<div class="example" style="margin-left: 3.2em">
 RereadLogAfterVerify=always
</div>




----

<div class="header">
<p>
Next: [[cvs: Editinfo#Editinfo|editinfo]], Previous: [[cvs: Commitinfo#Commitinfo|commitinfo]], Up: [[cvs: The commit support files#The commit support files|commit files]] &nbsp; |[[cvs: Index#SEC_Contents|Contents]]||[[cvs: Index#Index|Index]]|</p>
</div>
This document was generated on <i>a sunny day</i> using [http://www.nongnu.org/texi2html/ <i>texi2html</i>].
