RT-Client-Tools/scripts/rt-helper.pl
Bradley M. Kuhn 34e00ca5f0 Create rt-helper.pl and move one function to it.
Move function to rt-helper.pl that might be used in other Perl scripts.
2018-07-25 13:57:02 -07:00

31 lines
911 B
Perl

# -*- Perl -*-
# Copyright © 2018, Bradley M. Kuhn
# License: AGPL-3.0-or-later
###############################################################################
sub Outreachy_FindUniqueTicket(@) {
my @searchTerms = @_;
open(my $rtLsFH, "-|", "$RT_CMD", "ls", "-i", 'Queue = outreachy-interns ' .
"AND Subject LIKE '" . $ROUND . "' AND" .
join(" AND ", @searchTerms));
my $ticketSpec;
while (my $lsLine = <$rtLsFH>) {
chomp $lsLine;
if ($lsLine =~ /ticket/) {
if (defined $ticketSpec) {
$ticketSpec = undef;
last;
}
$ticketSpec = $lsLine;
}
}
close $rtLsFH;
return $ticketSpec;
}
###############################################################################
1;
###############################################################################
#
# Local variables:
# compile-command: "perl -c rt-helper.pl"
# perl-indent-level: 2
# End: