diff --git a/support-d/utils/filebug.pl b/support-d/utils/filebug.pl index 4c24587a66..5e9d569a80 100755 --- a/support-d/utils/filebug.pl +++ b/support-d/utils/filebug.pl @@ -14,7 +14,7 @@ my $default_components = "freeswitch-core"; sub getpass { ReadMode( "noecho"); print "Password: "; - chomp (my $pwd = <>); + chomp (my $pwd = ); ReadMode ("original"); return $pwd; } @@ -24,10 +24,12 @@ sub getfield { my $default = shift; print $prompt . ($default ? "[$default]: " : ""); - chomp (my $data = <>); + chomp (my $data = ); + if (!$data) { $data = $default; } + return $data; } @@ -56,6 +58,9 @@ my $hashtxt = `git log -1 --oneline 2>/dev/null`; my ($hash) = split(" ", $hashtxt); GetOptions( + 'bug=s' => \$opts{bug}, + 'attach' => \$opts{attach}, + 'comment=s' => \$opts{comment}, 'project=s' => \$opts{project}, 'summary=s' => \$opts{summary}, 'desc=s' => \$opts{desc}, @@ -88,12 +93,12 @@ if ($opts{components}) { } if (!$opts{user}) { - $opts{user} = getfield("User: "); + $opts{user} = getfield("User: "); } if (!$opts{pass} && !$opts{debug}) { - $opts{pass} = getpass(); - print "\n"; + $opts{pass} = getpass(); + print "\n"; } my $jira; @@ -104,6 +109,38 @@ if (!$opts{debug}) { $issue = $jira->GET("/issue/FS-7985") or die "login incorrect:"; } +if ($opts{bug}) { + if ($opts{comment}) { + + if ($opts{comment} eq "edit") { + $opts{comment} = get_text(); + } + + my $input = { + update => { + comment => + [{ + add => { + body => $opts{comment} + } + } + ] + } + }; + + $jira->PUT("/issue/" . $opts{bug}, undef, $input); + print "Comment Posted.\n"; + } + + if ($opts{attach}) { + $jira->attach_files($opts{bug}, @ARGV); + printf "%d file%s attached.\n", scalar @ARGV, scalar @ARGV == 1 ? "" : "s"; + } + + exit; +} + + #print $issue->{key}; #exit; @@ -174,5 +211,10 @@ if ($opts{debug}) { } else { $issue = $jira->POST('/issue', undef, $input) or die "Issue was not created:"; print "Issue Posted: " . $issue->{key}; + + if ($opts{attach}) { + $jira->attach_files($issue->{key}, @ARGV); + printf "%d file%s attached.\n", scalar @ARGV, scalar @ARGV == 1 ? "" : "s"; + } }