Make $round an argument to this sub.

Also, add $RT_CMD as an "our" variable.
This commit is contained in:
Bradley M. Kuhn 2018-07-25 14:32:05 -07:00
parent 7e52b5922b
commit 9867531a53
2 changed files with 17 additions and 7 deletions

View file

@ -1,11 +1,17 @@
# -*- Perl -*-
# Copyright © 2018, Bradley M. Kuhn
# License: AGPL-3.0-or-later
use strict;
use warnings;
use autodie qw(:all);
our $RT_CMD;
###############################################################################
sub Outreachy_FindUniqueTicket(@) {
my @searchTerms = @_;
sub Outreachy_FindUniqueTicket($@) {
my($round, @searchTerms) = @_;
open(my $rtLsFH, "-|", "$RT_CMD", "ls", "-i", 'Queue = outreachy-interns ' .
"AND Subject LIKE '" . $ROUND . "' AND" .
"AND Subject LIKE '" . $round . "' AND" .
join(" AND ", @searchTerms));
my $ticketSpec;
while (my $lsLine = <$rtLsFH>) {
@ -24,10 +30,13 @@ sub Outreachy_FindUniqueTicket(@) {
###############################################################################
sub Outreachy_FindMainTicketsInRound($) {
my($round) = @_;
open(my $rtLsFH, "-|", "$RT_CMD", "ls", "-i", 'Queue = outreachy-interns ' .
"AND Subject LIKE '" . $ROUND);
open(my $rtLsFH, "-|",
$RT_CMD, "ls", "-i", 'Queue = outreachy-interns ' .
"AND Subject LIKE '" . $round . "'");
print $round;
my @ticketSpecs;
while (my $lsLine = <$rtLsFH>) {
print $lsLine;
chomp $lsLine;
if ($lsLine =~ /ticket/) {
push(@ticketSpecs, $lsLine);

View file

@ -11,9 +11,10 @@ use Getopt::Long;
use File::Spec;
use Date::Manip qw(ParseDate UnixDate);
our $RT_CMD;
require 'rt-helper.pl';
my($PAYMENT_DIR, $VERBOSE, $INTERACTIVE, $PAYMENT_NUMBER, $RT_CMD, $INVOICE_LINE, $INTERN_SUCCESS_FILE,
my($PAYMENT_DIR, $VERBOSE, $INTERACTIVE, $PAYMENT_NUMBER, $INVOICE_LINE, $INTERN_SUCCESS_FILE,
$INTERN_FAIL_FILE, $LEDGER_ENTRY_DATE, $SVN_CMD, $ROUND, $TRAVEL_NOTICE_TICKET);
###############################################################################
@ -190,7 +191,7 @@ while (my $file = readdir $dh) {
push(@searchTerms, 'Subject LIKE "' . $name . '"');
}
# Find the ticket number for this intern.
my $ticket = Outreachy_FindUniqueTicket(@searchTerms);
my $ticket = Outreachy_FindUniqueTicket($ROUND, @searchTerms);
if (not defined $ticket) {
foreach my $term (@searchTerms) {
$ticket = Outreachy_FindUniqueTicket(($term));