#!/usr/bin/perl
#!/usr/bin/perl
=head1 NAME
p4_Anno_Bugs - Perforce trigger that will annotate all the bugs that are part of integration to submit change number
=head1 SYNOPSIS
*This is how it should be installed in the triggers table by running
"p4 triggers"
p4_Anno_Bugs change-commit //depot/release/... "/that/to/script/p4-AnnoBugs %change% %client% %user% %serverport%"
=head1 SEE ALSO
p4 help triggers
p4 help fixes
=head1 CONTACT
Thandesha V K - thanvk@gmail.com
=cut
use warnings;
use strict;
use Getopt::Long qw( GetOptions );
use Pod::Usage qw( pod2usage );
my $change_number = shift;
my $client_name = shift;
my $port = shift;
my $user = shift;
my $P4 = "/sbin/p4";
my %bug_list;
#Get the integrated fix details
my @p4_output = `$P4 -s -p $port -u $user -c $client_name fixes -i -c $change_number`;
foreach my $line ( @p4_output ) {
if ($line =~ m/info: (Job\d+) fixed by change \d+ on .*/) {
my $bugid = "$1";
if (!defined $bug_list{$bugid}) {
my $state = `$P4 fix -s same -c $change_number $bugid`;
if ( $?/256 ) {
$bug_list{$bugid} = 1;
print "INFO: Change $change_number fixed the BUG $bugid\n";
} else {
print "ERROR: Attempt to mark the BUG $bugid fixed in Change $change_number failed!\n";
}
}
}
}