info-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: log message verification


From: Joshua Davis
Subject: RE: log message verification
Date: Wed, 6 Dec 2000 01:02:50 -0500

On this subject, I have noticed that some clients (?) set the log message to
'no message' or something like that when no comments are entered.

A word of advice based on experience with a 20-year old (!!) version control
system from my previous job...

If your script just checks for a zero length log message, the programmers
will quickly figure out that they can just type in '.' or 'qwerty' or some
other nonsense.  If you use a perl script (as Dale suggests), you can easily
add some common 'nonsense messages' into your verifymsg code.  When the
version control system seems a bit smarter, the programmers will usually
enter a comment.

-----Original Message-----
From: address@hidden [mailto:address@hidden Behalf Of
Dale Miller
Sent: Tuesday, December 05, 2000 6:56 PM
To: address@hidden
Cc: address@hidden
Subject: Re: log message verification


address@hidden wrote:

> Hi all,
>
> I am having a problem.I want to check that a log msg is entered
> before commit.For this I want to check that the log msg is not null.
>
> I have the following line in verifymsg
>
> src /usr/cvssupport/verify.log
>
> and in verify.log I have the following script
> _________________________________________________
> msg = `head -1`
>
> if [ "$msg" = '' ];
>  then
> echo "No log message was entered;enter a log message and try again"
> exit 1
> else
> echo "Commit Success"
> exit 0
> fi
> __________________________________________________
> But this is aborting the commit even when a msg is entered.Am I doing
> this correctly?will the firstline in the code above get the log msg
> into the variable msg?Else how do I get the log message into that
> variable?? Pls help.
>
> Thanks a lot,
> Paddy Thomas

Paddy,

Try adding
echo $msg | cat -tev
after your msg = `head -1` line to see what it actually contains.
The cat options will show you the end of line or any control
characters that might be present.

I use a perl program I enforce that a person starts the commit
message with a valid System Change Request (SCR) number.
I have a crontab that maintains a file of active SCRs and I
use it to verify the comment entry.

The perl program gets the comment from STDIN.
You cannot alter the comment that the commit will use but
you can verify the contents.

My program displays the SCR number and title to the screen
and then does a normal exit on a match.

I was asking the person to confirm that the SCR number was
valid, however, when I moved to using pserver I had to comment
out the call to the subroutine because you cannot get interaction
with pserver from STDIN.  I tried many things to see if I
could get interaction, but I finally forced it to quite looping
after 4 failures, and later just commented out the call.

You might get some ideas from it.

---------------- cut here ----------------------------
#!/usr/local/bin/perl -ws
#  verifymsg_SCR   Dale Miller   16-AUG-1999
#
#  $Id: verifymsg_SCR,v 1.2 2000/09/06 22:04:00 miller Exp $
#
#  This program is called by $CVSROOT/CVSROOT/verifymsg
#  and is used to verify that the log message starts with a
#  SCR number with the three letters SCR before the 8 digits.
#
#  If the SCRyyyydddd is not supplied the commit fails.
#

$scrfile = "/sdhs_code/SDHSU/cm/tools/open_SCRs.txt" unless defined
$scrfile;

$reply = "xx";  #initialize
$counter = 0;   #initialize

chop($scr = <>);

if (-r "$scrfile") {
    if ($scr !~ /(^SCR\d{8})(\s+|$)/) {
        print "$scr\n";
        print "*******************************************    ERROR\n";
        print "*******************************************\n";
        print "Must start your comment with \"SCRyyyydddd \"\n";
        print "       The commit has been aborted!\n";
        print "*******************************************\n";
        print "*******************************************    ERROR\n";
        exit 1;
    } else {
        $scr = $scr;
        $scr =~ s/^SCR(\d{8}).*$/$1/;
        $match = `grep $scr $scrfile`;
        chomp $match;
        if ($match eq "") {
            print "*******************************************
ERROR\n";
            print "*******************************************\n";
            print "SCR$scr is not active or not a valid number\n";
            print "*******************************************\n";
            print "*******************************************
ERROR\n";
            exit 1;
        } else {
            $status = ""; #not used (-w)
            ($status, $number, $title) = split(/\s+/, $match, 3);
            print "SCR$number: $title\n";
            #&ask_if_correct;
            exit 0;
        }
    }
} else {
    print "$scrfile is not readable or does not exist.\n";
    print "Please notify CM staff\n";
    exit 1;
}

sub ask_if_correct {
    print "Is this the correct SCR? (y|n): ";

    chop($reply = <STDIN>);
    until ($reply =~ /^[yn]/i) {
        print "Please enter \"y\" or \"n\": ";
        chop($reply = <STDIN>);
        $counter++;
        if ($counter > 4) {
            $reply = "n";
        }
    }

    if ($reply =~ /^n/i) {
        print "Please try again using the proper SCR number\n";
        print "********************************************\n";
        exit 1;
    }
}




_______________________________________________
Info-cvs mailing list
address@hidden
http://mail.gnu.org/mailman/listinfo/info-cvs




reply via email to

[Prev in Thread] Current Thread [Next in Thread]