info-cvs
[Top][All Lists]
Advanced

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

Re: Getting log messages via email


From: Thomas S. Urban
Subject: Re: Getting log messages via email
Date: Tue, 18 Dec 2001 09:23:27 -0800
User-agent: Mutt/1.3.21i

On Tue, Dec 18, 2001 at 05:08:53PM +0100, Joern Kersten wrote:
> Hi!
> 
> I'd like to get an email notification *including the log message* when
> somebody is committing changes to certain files. Currently, I'm using
> cvs watch and the standard command in CVSROOT/notify,
> 
> ALL mail %s -s "CVS notification"

This might be overkill for what you want, but I use a perl script to
assemble and format the mail message and also link to your cvsweb
interface for viewing the differences.

This is what I have in CVSROOT/notify:
ALL /usr/local/cvs/bin/cvsnotify.pl %s

And this is the perl in /usr/local/cvs/bin/cvsnotify.pl (change cvsroot
and the CVS web url and whatever else to make it work for you):

--- begin cvsnotify.pl ---
#!/usr/bin/perl
# notes:
#
# this script is run by CVS to notify users of changes
# a copy or link of this should be placed in /usr/local/cvs/bin,
# or the location/name should be changed in the 'notify' support
# file (check out in CVSROOT)
#
#    - TODO: doesn't tell what happened (add,change,remove)
#    - TODO: doesn't work right for removed files (URL, log)
#    - TODO: doesn't work right for added files (URL, log)
#    - TODO: use env $CVSROOT for $cvsroot
#

# config vars
$cvsroot = '/YOUR/CVSROOT';
$cvsweb_base = "http://YOUR.CVSWEB.MACHINE/cgi-bin/cvsweb.cgi";;

# user's email address, aliases from 'users' file in CVSROOT
$useraddr = shift @ARGV;

# notify info is passed in on <stdin>
@lines = <>;

$line = shift @lines;

# remove trailing newline
chop $line;

# module and file
($module,$file) = split (' ',$line);

# ignore lines
shift @lines;
shift @lines;

# changed
$line = shift @lines;
($nop, $changer) = split (' ',$line);

# use rlog to get 'rcs' info
$rlog_file = $cvsroot . $module . "/" . $file . ",v";
$rlog_cmd = "rlog -zLT -r " . $rlog_file;

open (RLOGOUTPUT, "$rlog_cmd |") or die "can't run rlog";

while (<RLOGOUTPUT>)
{
        if (/^head: (.*)$/) { $head = $1; }
        if (/^branch: (.*)$/) { $branch = $1; }
        if (/^date: /) { last ; }
}

# assemble log message
while (<RLOGOUTPUT>)
{
        if (/^=========================================/) { last; }
        push @log_msg, $_;
}

close (RLOGOUTPUT);

# assemble mail message
open (MAILINP, "| mail -s '[CVS notify] $module changed' $useraddr");

print MAILINP "This is an automated message generated by CVS.\n";
print MAILINP "If you do not wish to receive these messages, use\n";
print MAILINP "'cvs watch' to modify your watches.\n\n";
print MAILINP "module: $module\n";
print MAILINP "file: $file\n";
print MAILINP "head: $head\n";
print MAILINP "date: $dat\n";
print MAILINP "log message:\n", join ('', @log_msg), "\n\n";

$head =~ m/^([^.]*)\.(.*)$/;
$whole = $1;
$part = $2 - 1;
$lhead = $whole . "." .  $part;

print MAILINP "see changes at: 
$cvsweb_base/$module/$file.diff?r1=text&tr1=$lhead&r2=text&tr2=$head&f=h";

close MAILINP;

--- end cvsnotify.pl ---


HTH
Scott

-- 
If you can't be good, be careful.  If you can't be careful, give me a call.



reply via email to

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