New Trigger
Here are the requirements as I understand them for the trigger that Steve Lipson wants for the SQL checkins. Basically he desires a trigger that will capture the checkin comment and other information and insert that information in the form of a comment at the top of the checked in element. This trigger will:
- Be a postop trigger for the checkin action
- Not be an all element trigger rather it will be attached to certain file elements in the vob
- Be made for the <fill in vob name here> vob
- Only work on file elements - directory elements are to be skipped
- Only work on file elements that have an extension of .sql - other elements will be skipped
Roughly the psuedo code for this trigger will be:
# Get name of element and its type $pname = $ENV{CLEARCASE_PN}; $element_type = $ENV{CLEARCASE_ELTYPE}; # Skip directories and elements that aren't .sql exit if $element_type =~ /directory/i || $pname !~ /\.sql$/i; # Get comment and user $comment = $ENV{CLEARCASE_COMMENT}; $userid = $ENV{CLEARCASE_USER}; # Format timestamp $timestamp = getCurrentTime; # Parse output of lsactivity -cact -long ($activity_id, $activity_title, $activity_owner) = parseLSActivity; # Open up $pname for reading and $pname.trig for writting open PNAME_IN, $pname or die "Unable to open $pname for reading - $!\n"; open PNAME_OUT, ">$pname.trig" or dir "Unable to open $pname.trig for writing - $!\n"; # Add comment to top of file print $PNAME_OUT <<END; -- Date: $timestamp -- Activity: $activity_id: $activity_title -- Owner: $activity_owner ($userid) -- Comment: $comment END # Append $pname while () { print PNAME_OUT $_; } # while close PNAME; close PNAME_OUT; # Switch $pname.trig -> $pname unlink $pname; rename "$pname.trig", $pname; # Allow checkin to proceed exit 0;