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