2 ################################################################################
4 # File: CheckinPostop.pl
5 # Description: This script is run on check in post op. It will pick up the
6 # bug IDs from the comment and label the elements that have just
8 # Author: Andrew@DeFaria.com
9 # Created: Fri Oct 26 15:32:12 2001
11 # Modifications:10/22/2002: Changed to not complain about missing bug IDs if
12 # the branch was main.
13 # 04/11/2003: Changed to support multiple bug IDs in the comment.
14 # (c) Copyright 2003, Andrew@DeFaria.com, all rights reserved
16 ################################################################################
20 # Add the appropriate path to our modules to @INC array. We use ipconfig to
21 # get the current host's IP address then determine whether we are in the US
22 # or China. If neither then we fallback to using T:/Triggers.
23 my @ipconfig = grep (/IP Address/, `ipconfig`);
24 my ($ipaddr) = ($ipconfig[0] =~ /(\d{1,3}\.\d{1,3}.\d{1,3}\.\d{1,3})/);
26 # US is in the subnets of 192 and 172 while China is in the subnet of 10
27 if ($ipaddr =~ /^192|^172/) {
28 unshift (@INC, "//sons-clearcase/Views/official/Tools/lib");
29 } elsif ($ipaddr =~ /^10/) {
30 unshift (@INC, "//sons-cc/Views/official/Tools/lib");
32 die "Internal Error: Unable to find our modules!\n"
38 # The following environment variables are set by Clearcase when this
40 my $comment = $ENV{CLEARCASE_COMMENT};
41 my $branch = $ENV{CLEARCASE_BRTYPE};
42 my $pname = $ENV{CLEARCASE_PN};
43 my $user = $ENV{CLEARCASE_USER};
48 my @fields = split /\W/,$comment;
50 # Use associative array to insure uniqueness
56 if (/BUGS2[0-9]{8}/) {
61 foreach (keys %bugids) {
71 my $result = system "cleartool lstype lbtype:$label@\\salira > /dev/null 2>&1";
73 return $result if ($result eq 0);
75 $result = system "cleartool mklbtype -nc -shared -pbranch $label@\\salira";
78 clearlog "Created label for $label";
80 clearlogmsg "Unable to mklbtype for $label (Error #: $result)";
86 foreach my $bugid (ExtractBugIDs ($comment)) {
87 if (mklabel ($bugid) eq 0) {
88 my $result = system "cleartool mklabel -replace $bugid \"$pname\"";
91 clearlogmsg "Unable to apply label $bugid to $pname (Error #: $result)";
94 clearlog "Attached label $bugid to $pname";
97 clearlog "Successful postcheckin of $pname on $branch branch with bug ID $bugid";