4 # XXX: FIXME: handle multiple '-f logfile' arguments
6 # XXX -- I HATE Perl! This *will* be re-written in shell/awk/sed soon!
9 # Usage: log.pl [-u user] [[-m mailto] ...] [-s] -f logfile 'dirname file ...'
11 # -u user - $USER passed from loginfo
12 # -m mailto - for each user to receive cvs log reports
13 # (multiple -m's permitted)
14 # -s - to prevent "cvs status -v" messages
15 # -f logfile - for the logfile to append to (mandatory,
16 # but only one logfile can be specified).
18 # here is what the output looks like:
20 # From: woods@kuma.domain.top
21 # Subject: CVS update: testmodule
23 # Date: Wednesday November 23, 1994 @ 14:15
26 # Update of /local/src-CVS/testmodule
27 # In directory kuma:/home/kuma/woods/work.d/testmodule
38 # (and for each file the "cvs status -v" output is appended unless -s is used)
40 # ==================================================================
41 # File: test3 Status: Up-to-date
43 # Working revision: 1.41 Wed Nov 23 14:15:59 1994
44 # Repository revision: 1.41 /local/src-CVS/cvs/testmodule/test3,v
48 # local-v2 (revision: 1.7)
49 # local-v1 (revision: 1.1.1.2)
50 # CVS-1_4A2 (revision: 1.1.1.2)
51 # local-v0 (revision: 1.2)
52 # CVS-1_4A1 (revision: 1.1.1.1)
55 $cvsroot = $ENV{'CVSROOT'};
63 # parse command line arguments
69 $users = "$users " . shift @ARGV;
70 } elsif ($arg eq '-u') {
72 } elsif ($arg eq '-f') {
73 ($logfile) && die "Too many '-f' args";
74 $logfile = shift @ARGV;
75 } elsif ($arg eq '-s') {
78 ($donefiles) && die "Too many arguments!\n";
80 @files = split(/ /, $arg);
84 # the first argument is the module location relative to $CVSROOT
86 $modulepath = shift @files;
88 $mailcmd = "| Mail -s 'CVS update: $modulepath'";
90 # Initialise some date and time arrays
92 @mos = (January
,February
,March
,April
,May
,June
,July
,August
,September
,
93 October
,November
,December
);
94 @days = (Sunday
,Monday
,Tuesday
,Wednesday
,Thursday
,Friday
,Saturday
);
96 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
99 # get a login name for the guy doing the commit....
102 $login = getlogin || (getpwuid($<))[0] || "nobody";
105 # open log file for appending
107 open(OUT
, ">>" . $logfile) || die "Could not open(" . $logfile . "): $!\n";
109 # send mail, if there's anyone to send to!
112 $mailcmd = "$mailcmd $users";
113 open(MAIL
, $mailcmd) || die "Could not Exec($mailcmd): $!\n";
116 # print out the log Header
119 print OUT
"****************************************\n";
120 print OUT
"Date:\t$days[$wday] $mos[$mon] $mday, $year @ $hour:" . sprintf("%02d", $min) . "\n";
121 print OUT
"Author:\t$login\n\n";
125 print MAIL
"Date:\t$days[$wday] $mos[$mon] $mday, $year @ $hour:" . sprintf("%02d", $min) . "\n";
126 print MAIL
"Author:\t$login\n\n";
129 # print the stuff from logmsg that comes in on stdin to the logfile
142 # after log information, do an 'cvs -Qq status -v' on each file in the arguments.
144 if ($dostatus != 0) {
146 $file = shift @files;
148 print OUT
"[input file was '-']\n";
150 print MAIL
"[input file was '-']\n";
154 $pid = open(RCS
, "-|");
157 die "fork failed: $!";
161 exec 'cvs', '-nQq', 'status', '-v', $file;
162 die "cvs exec failed: $!";
175 die "Write to $logfile failed" if $?
;
178 die "Pipe to $mailcmd failed" if $?
;