#!/usr/bin/env perl # -*-Perl-*- # # # Perl filter to handle post-tag checks. # # Contributed by Mike Sutton use strict vars; use Getopt::Std; # # Configurable options # # Constants (remember to protect strings from RCS keyword substitution) # my $id = getpgrp(); # You *must* use a shell that does setpgrp()! my $outfile="$ENV{CVSROOT}/CVSROOT/tag.log"; my $LAST_FILE = "/tmp/#cvs.lastdir.$id"; # must match name in tag_prep.pl my $accumfile = "/tmp/#cvs.tag_accum.$id"; # # Main Body # # parse command line arguments # my %opts = (); getopts('-d', \%opts); my $debug = 1 if (exists($opts{'d'})); my $tagname = shift; my $tagop = shift; my $repodir = shift; my $cvsroot = $ENV{'CVSROOT'}; if ($debug != 0) { print STDERR "dir - ", $repodir, "\n"; print STDERR "files - ", join(":", @ARGV), "\n"; print STDERR "id - ", $id, "\n"; } # Get the last directory name # open(FILE, "<$LAST_FILE") || die("Cannot open $LAST_FILE, stopped"); my $lastdir = ; chomp $lastdir; close(FILE); open(OF, ">>$accumfile") or die "Can't open $accumfile\n"; my $baserepo = $repodir; $baserepo =~ s|$cvsroot||; $baserepo =~ s,^/,,; my $fname = shift; my $revnum = shift; while (defined($revnum)){ print OF "$baserepo/$fname\t$revnum\n"; $fname = shift; $revnum = shift; } if ($repodir ne $lastdir){ print OF "\n"; close(OF); }else { close(OF); open(OF, "<$accumfile") or die "Can't open $accumfile\n"; my @accumlines = ; close(OF); my $date = `date`; chomp $date; my $user = ($ENV{'CVS_USER'}) ? $ENV{'CVS_USER'}:$ENV{'LOGNAME'}; open(LF, ">>$outfile") or die "Can't open $outfile\n"; print LF " Tag: $tagname Operation: $tagop Date: $date User: $user "; print LF @accumlines; close(LF); unlink $accumfile, $LAST_FILE; # print STDERR sprintf("Current directory %s IS LAST directory %s.\n", # $repodir, $lastdir); } exit(0);