#!/usr/bin/perl # # ciabot -- Mail a CVS log message to a given address, for the purposes of CIA # # Loosely based on cvslog by Russ Allbery
# Copyright 1998 Board of Trustees, Leland Stanford Jr. University # # Copyright 2001, 2003 Petr Baudis # # This program is free software; you can redistribute it and/or modify it under # the terms of the GNU General Public License version 2, as published by the # Free Software Foundation. # # This program is designed to run from the loginfo CVS administration file. It # takes a log message, massaging it and mailing it to the address given below. # # Its record in the loginfo file should look like: # # ALL $CVSROOT/CVSROOT/ciabot.pl %s $USER projectname # use strict; use vars qw ($project $from_email $dest_email $max_lines $sync_delay $commit_template $branch_template $trimmed_template); ### Configuration # Project name (as known to CIA). $project = $ARGV[2]; # The from address in the generated mails. $from_email = 'address@hidden'; # Mail all reports to this address. $dest_email = 'address@hidden'; # The maximal number of lines the log message should have. $max_lines = 6; # Number of seconds to wait for possible concurrent instances. CVS calls up # this script for each involved directory separately and this is the sync # delay. 5s looks as a safe value, but feel free to increase if you are running # this on a slower (or overloaded) machine or if you have really a lot of # directories. $sync_delay = 4; # The template string describing how the commit message should look like. # Expansions: # %user% - who committed it # %tag% - expands to the branch tag template ($branch_template), if the # commit hapenned in a branch # %module% - the module where the commit happenned # %path% - the longest common path of all the committed files # %file% - the file name or number of files (and possibly number of dirs) # %trimmed%- a notice about the log message being trimmed, if it is # ($trimmed_template) # %logmsg% - the log message $commit_template = '{green}%user%{normal}%tag% | {purple}%module%{normal}/%path% (%file%): %trimmed%%logmsg%'; # The template string describing how the branch tag name should look like. # Expansions: # %tag% - the tag name $branch_template = ' {yellow}%tag%{normal}'; # The template string describing how the trimming notice should look like. # Expansions: # none $trimmed_template = '(log message trimmed)'; ### The code itself use vars qw ($user $module $tag @files $logmsg); my @dir; # This array stores all the affected directories my @ci; # This array is mapped to the @dir array and contains files affected # in each directory my $logmsg_lines; ### Input data loading # These arguments are from %s; first the relative path in the repository # and then the list of files modified. @files = split (' ', $ARGV[0]); $dir[0] = shift @files or die "$0: no directory specified\n"; $ci[0] = "@files" or die "$0: no files specified\n"; $module = $dir[0]; $module =~ s#/.*##; # Figure out who is doing the update. $user = $ARGV[1]; # Parse stdin (what's interesting is the tag and log message) while (