]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-10372: [Build-System,fs-utils] #resolve
authorAnthony Minessale <anthm@freeswitch.org>
Tue, 6 Jun 2017 18:56:15 +0000 (13:56 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Tue, 6 Jun 2017 18:56:24 +0000 (13:56 -0500)
support-d/utils/filebug.pl
support-d/utils/fixbug.pl

index 7c22e2aaeeb461f38cb40767ebd7b5905fda9114..50fefa04a9750d8b386af76c41669d1f9b44f6fd 100755 (executable)
@@ -148,6 +148,20 @@ if ($opts{bug}) {
        printf "%d file%s attached.\n", scalar @ARGV, scalar @ARGV == 1 ? "" : "s";
     }
 
+    if ($opts{versions_array}) {
+       $input = {
+
+           update => {
+               fixVersions => [
+                   {set => $opts{versions_array}}
+                   ]
+           }
+       };
+
+       $jira->PUT("/issue/" . $opts{bug}, undef, $input);
+    }
+
+
     exit;
 }
 
@@ -227,6 +241,22 @@ if ($opts{debug}) {
     $issue = $jira->POST('/issue', undef, $input) or die "Issue was not created:";
     print "Issue Posted: " . $issue->{key};
 
+    if ($opts{versions_array}) {
+       $input = {
+
+           update => {
+               fixVersions => [
+                   {set => $opts{versions_array}}
+                   ]
+           }
+       };
+
+       $jira->PUT("/issue/" . $issue->{key}, undef, $input);
+
+       print "Fix versions updated for issue " . $issue->{key};;
+    }
+    
+
     if ($opts{attach}) {
        $jira->attach_files($issue->{key}, @ARGV);
        printf "%d file%s attached.\n", scalar @ARGV, scalar @ARGV == 1 ? "" : "s";
index b304f8a1f6ed9bf9934f638097839d2b81beb4c5..aeb5b5f1dd44b91a93b580af4cf91853b58ffe09 100755 (executable)
@@ -3,22 +3,55 @@
 use XML::Simple;
 use Data::Dumper;
 use Getopt::Long qw(GetOptions);
+use Term::ReadKey;
+use JIRA::REST;
 
 my %opts;
 
+sub getpass {
+  ReadMode( "noecho");
+  print "Password: ";
+  chomp (my $pwd = <STDIN>);
+  ReadMode ("original");
+  return $pwd;
+}
+
+sub getfield {
+    my $prompt = shift;
+    my $default = shift;
+
+    print $prompt . ($default ? "[$default]: " : "");
+    chomp (my $data = <STDIN>);
+    
+    if (!$data) {
+       $data = $default;
+    }
+
+    return $data;
+}
+
 GetOptions(
     'bug=s' => \$opts{bug},
     'msg=s' => \$opts{msg},
+    'user=s' => \$opts{user},
+    'pass=s' => \$opts{pass},
     'debug' => \$opts{debug},
     'noresolve' => \$opts{noresolve},
     'append=s' => \$opts{append},
     'comment=s' => \$opts{comment},
-    'author=s' => \$opts{author}
-    ) or die "Usage: $0 -bug <bug-id> [-m [edit|<msg>]] [-append <msg>] [-debug] <files>\n";
+    'versions=s' => \$opts{versions},
+    'author=s' => \$opts{author},
+    'auth' => \$opts{auth}
+    ) or die "Usage: $0 -bug <bug-id> [--auth] [-m [edit|<msg>]] [--append <msg>] [--debug] <files>\n";
 
 
 $opts{bug} or $opts{bug} = shift;
 
+if ($opts{versions}) {
+    $opts{auth} = 1;
+    $opts{versions_array} = [map {{name => $_}} split(" ", $opts{versions})];
+}
+
 my $url = "https://freeswitch.org/jira/si/jira.issueviews:issue-xml/$opts{bug}/$opts{bug}.xml";
 my $cmd;
 my $prog = `which curl` || `which wget`;
@@ -27,38 +60,73 @@ my $post = " \#resolve";
 
 chomp $prog;
 
-$prog || die "missing url fetch program, install curl or wget";
+if ($opts{auth}) {
+    if (!$opts{user}) {
+       $opts{user} = getfield("User: ");
+    }
+    
+    if (!$opts{pass} && !$opts{debug}) {
+       $opts{pass} = getpass();
+       print "\n";
+    }
+
+    $jira = JIRA::REST->new('https://freeswitch.org/jira', $opts{user}, $opts{pass}) or die "login incorrect:";
+    $issue = $jira->GET("/issue/FS-7985") or die "login incorrect:";
+
+    my $issue = $jira->GET("/issue/" . $opts{bug});
+
+    $component = join(",", map {$_->{name}} @{$issue->{fields}->{components}});
+    $summary = $issue->{fields}->{summary};
+
+
+    if ($opts{versions_array}) {
+       $input = {
+
+           update => {
+               fixVersions => [
+                   {set => $opts{versions_array}}
+                   ]
+           }
+       };
+       
+       $jira->PUT("/issue/" . $opts{bug}, undef, $input);
+    }
 
-if ($prog =~ /wget/) {
-  $cmd = "$prog -O -";
 } else {
-  $cmd = $prog;
-}
+    $prog || die "missing url fetch program, install curl or wget";
 
-my $xml = `$cmd $url 2>/dev/null`;
-if ($opts{debug}) {
-    print "URL $url\n";
-    print $xml;
-}
+    if ($prog =~ /wget/) {
+       $cmd = "$prog -O -";
+    } else {
+       $cmd = $prog;
+    }
 
-my $xs= new XML::Simple;
-my $r = $xs->XMLin($xml);
+    my $xml = `$cmd $url 2>/dev/null`;
+    if ($opts{debug}) {
+       print "URL $url\n";
+       print $xml;
+    }
 
-my $sum = $r->{channel}->{item}->{summary};
-$sum =~ s/\"/\\"/g;
+    my $xs= new XML::Simple;
+    my $r = $xs->XMLin($xml);
 
-my $component = $r->{channel}->{item}->{component};
+    my $sum = $r->{channel}->{item}->{summary};
+    $sum =~ s/\"/\\"/g;
 
-if(ref($component) eq 'ARRAY') {
-  $component = join(",", @{$component});
-}
+    my $component = $r->{channel}->{item}->{component};
 
-$component =~ s/\"/\\"/g;
+    if(ref($component) eq 'ARRAY') {
+       $component = join(",", @{$component});
+    }
+
+    $component =~ s/\"/\\"/g;
+}
 
 if ($opts{noresolve}) {
     $post = "";
 }
 
+
 if ($opts{msg} eq "edit") {
   $auto = 0;
   $opts{msg} = undef;