From 6441f5c8ff6f19fbbdca0af1176e72f73cf4c516 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 18 Aug 2015 18:26:52 -0500 Subject: [PATCH] FS-7988 #resolve [We can't file bugs from the command line] --- support-d/utils/filebug.pl | 127 +++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100755 support-d/utils/filebug.pl diff --git a/support-d/utils/filebug.pl b/support-d/utils/filebug.pl new file mode 100755 index 0000000000..dcb4f014e8 --- /dev/null +++ b/support-d/utils/filebug.pl @@ -0,0 +1,127 @@ +#!/usr/bin/perl +#use strict; + +use Getopt::Long qw(GetOptions); +use Term::ReadKey; +use JIRA::REST; +use Data::Dumper; + +sub getpass { + ReadMode( "noecho"); + print "Password: "; + chomp (my $pwd = <>); + ReadMode ("original"); + return $pwd; +} + +sub getuser { + print "User: "; + chomp (my $usr = <>); + return $usr; +} + +sub get_text { + my @chars = ("A".."Z", "a".."z"); + my $string; + $string .= $chars[rand @chars] for 1..8; + + my $editor = $ENV{"EDITOR"} || $ENV{"VISUAL"} || `which emacs` || `which vi`; + + system("$editor /tmp/TEXT.$string"); + my $text = `cat /tmp/TEXT.$string`; + unlink("/tmp/TEXT.$string"); + return $text; +} + +#my $user = getuser(); +#my $pass = getpass(); + +my %opts; + +my $hashtxt = `git log -1 --oneline 2>/dev/null`; +my ($hash) = split(" ", $hashtxt); + +GetOptions( + 'summary=s' => \$opts{summary}, + 'desc=s' => \$opts{desc}, + 'components=s' => \$opts{components}, + 'hash=s' => \$opts{hash}, + 'user=s' => \$opts{user}, + 'pass=s' => \$opts{pass}, + 'type=s' => \$opts{type}, + 'debug' => \$opts{debug}, + ) or die "Usage: $0 --debug --from NAME\n"; + + +if ($opts{components}) { + $opts{components_array} = [map {{name => $_}} split(" ", $opts{components})]; +} else { + $opts{components_array} = [map {{name => $_}} qw(freeswitch-core)]; +} + + +#print Dumper \%opts; +#exit; + +if (!$opts{user}) { + $opts{user} = getuser(); +} + +if (!$opts{pass}) { + $opts{pass} = getpass(); +} + +my $jira = JIRA::REST->new('https://freeswitch.org/jira', $opts{user}, $opts{pass}) or die "login incorrect:"; +my $issue = $jira->GET("/issue/FS-7985") or die "login incorrect:"; +#print Dumper $issue; +#exit; + +if (!$opts{type}) { + $opts{type} = "Bug"; +} + +if (!$opts{summary}) { + die "missing summary:"; +} + +if (!$opts{desc}) { + $opts{desc} = get_text(); + + if (!$opts{desc}) { + die "missing desc:"; + } +} + +if (!$opts{hash}) { + $opts{hash} = $hash; + + if (!$opts{hash}) { + $opts{hash} = "N/A"; + } +} + + + +my $issue = $jira->POST('/issue', undef, { + fields => { + project => { key => 'FS' }, + issuetype => { name => $opts{type} }, + summary => $opts{summary}, + description => $opts{desc}, + customfield_10024 => $opts{hash}, + customfield_10025 => $opts{hash}, + components => $opts{components_array} + }, + }); + + +print "Issue Posted"; + + +__END__ + +my $jira = JIRA::REST->new('https://freeswitch.org/jira', $user, $pass); + +#$issue = $jira->GET("/issue/FS-7985"); +#print Dumper $issue; +