Fix function and add verbosity.

This wasn't functioning right after my last changes, but this should get it
working.
This commit is contained in:
Bradley M. Kuhn 2018-08-05 19:54:13 -07:00
parent c7811bacb9
commit d1dc3fb8c3

View file

@ -6,6 +6,7 @@ use warnings;
use autodie qw(:all);
our $RT_CMD;
our $VERBOSE;
###############################################################################
sub Outreachy_FindUniqueTicket($@) {
@ -50,11 +51,15 @@ sub GetLinksForTicket($) {
open(my $rtLinksFH, "-|", "$RT_CMD", "show", $ticketSpec . '/links');
my $type = 'NONE';
while (my $linksLine = <$rtLinksFH>) {
if ($linksLine =~ m%\s*([^:]+)\s:%) {
print STDERR "rt-helper: GetLinksForTicket: processing line: $linksLine\n" if ($VERBOSE > 9);
if ($linksLine =~ m%^([^:\s]+)\s*:%) {
$type = $1;
print STDERR "rt-helper: GetLinksForTicket: type is now $type\n" if ($VERBOSE > 7);
}
if ($linksLine =~ m%rt.*(ticket/\d+)\s*,?\s*$%) {
push(@{$linked{$type}}, $1) if $type !~ /(NONE|id)/i;
if ($type !~ /(NONE|id)/i and $linksLine =~ m%rt.*(ticket/\d+)\s*,?\s*$%) {
my $val = $1;
push(@{$linked{$type}}, $val);
print STDERR "rt-helper: GetLinksForTicket: add link of $val for $type\n" if ($VERBOSE > 7);
}
}
close $rtLinksFH;