#!perl # This trigger is believed to work with ccperl (5.001) but the # triggerseries stuff requires a modern version. require 5.001; # Allow knowledgeable users to short-circuit the trigger with this EV. BEGIN { exit 0 if $ENV{CLEARCASE_SKIP_CHECKIN_POST} } # Conceptually this is "use constant MSWIN ..." but ccperl can't do that. # Perl 5.005 and above uses MSWin32, prior versions use Windows_NT. sub MSWIN { ($^O || $ENV{OS}) =~ /MSWin32|Windows_NT/i ? 1 : 0 } # This will (a) modify %ENV to use /-style paths and (b) cause # responses to be replayed for 2nd-through-nth firings. use ClearCase::ClearPrompt 1.26 qw(clearprompt /ENV /TRIGGERSERIES); # On Windows we must rely on PATH to find cleartool. On Unix, # /usr/atria/bin/cleartool is always a valid path so we use it. my $CT = MSWIN() ? 'cleartool' : '/usr/atria/bin/cleartool'; # The name we were run as for error msgs. (my $prog = $0) =~ s%.*[/\\]%%; my $pn = $ENV{CLEARCASE_PN}; my $xpn = $ENV{CLEARCASE_XPN} || $pn; # Don't bother collecting this extra data for directories. exit 0 if -d $pn; # Special case - some elems/vobs/people don't require all this data. exit 0 if ($pn =~ m%/private/%) && !defined($ENV{CLEARCASE_TRACE_TRIGGERS}); # Special case - since Makefiles may do auto-checkins. exit 0 if defined $ENV{MAKEFLAGS}; # If this is a WEB interface (ATRIA_WEB_GUI=1), no prompt is possible. if (! $ENV{ATRIA_WEB_GUI}) { # Unless CRNUM has been supplied in the environment, prompt for it. # Then validate the supplied value. Try 5 times to get a valid response, # after that assume 0. for (1..5) { my $crnum = $ENV{CRNUM} || clearprompt(qw(text -def 0 -pro), 'Change Request(s):'); $crnum =~ s/\s+//g; $crnum ||= '0'; # in case we ended up with a null string if ($crnum =~ /^\d[\d,]*$/) { $ENV{CRNUM} = $crnum; last; } else { warn "$prog: CRNUM must be a comma-separated list of positive integers ($crnum)\n"; $ENV{CRNUM} = undef; } } } # Now attach the CRNUM attribute (unless it's 0). # Compare as a string in case CRNUM=x,y,z ... exit 0 unless defined $ENV{CRNUM} && $ENV{CRNUM} ne '0'; # Funky quoting needed for a string-valued attribute ... my $val = qq("$ENV{CRNUM}"); # Funky extra quoting for &@#%$ Windows cmd shell. $val = qq(\\"$val\\") if MSWIN(); # No need to see the "created attribute" msg. close(STDOUT) unless $ENV{CLEARCASE_TRACE_TRIGGERS}; system $CT, qw(mkattr -nc -rep ChangeRequest), $val, $xpn; __END__ =pod =head1 DESCRIPTION This trigger is used to associate change request (aka bug) numbers with new versions. It prompts for this, or will accept a CRNUM environment variable. We must store this as a string instead of an integer-valued attribute in case the user wants to supply a comma-separated list of fixed bugs. =head1 AUTHOR David Boyce (dsb@cleartool.com) =head1 COPYRIGHT Copyright (c) 1998-2002 David Boyce (dsb@cleartool.com), Clear Guidance Consulting. All rights reserved. =cut