# -*- 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; } ############################################################################### sub GetStatusFromTicket($) { my($ticketSpec) = @_; my $status; open(my $statusFH, "-|", "$RT_CMD", "show", "-f", 'Status', $ticketSpec); while (my $statusLine = <$statusFH>) { if ($statusLine =~ /\s*Status\s*:\s*(\S+)\s*$/) { $status = $1; last; } } close $statusFH; return $status; } ############################################################################### sub GetCustomFieldForTicket($$) { my($ticketSpec, $customField) = @_; open(my $rtCustomFH, "-|", "$RT_CMD", "show", "-f", 'CF.{' . $customField .'}', $ticketSpec); my $val; while (my $customFieldLine = <$rtCustomFH>) { chomp $customFieldLine; if ($customFieldLine =~ /^\s*CF\s*.\s*{$customField}\s*:\s*(\S+)\s*$/) { $val = $1; last; } } close $rtCustomFH; return $val; } ############################################################################### 1; ############################################################################### # # Local variables: # compile-command: "perl -c rt-helper.pl" # perl-indent-level: 2 # End: