FS-7988 FS-7989 cleanup scripts

This commit is contained in:
Anthony Minessale 2015-08-18 18:46:21 -05:00
parent 5bee986fb7
commit fa8f304248
2 changed files with 24 additions and 12 deletions

View File

@ -46,8 +46,7 @@ GetOptions(
'user=s' => \$opts{user}, 'user=s' => \$opts{user},
'pass=s' => \$opts{pass}, 'pass=s' => \$opts{pass},
'type=s' => \$opts{type}, 'type=s' => \$opts{type},
'debug' => \$opts{debug}, ) or die "Usage: $0 -summary <summary> -desc <desc> ....\n";
) or die "Usage: $0 --debug --from NAME\n";
if ($opts{components}) { if ($opts{components}) {

View File

@ -2,11 +2,18 @@
use XML::Simple; use XML::Simple;
use Data::Dumper; use Data::Dumper;
use Getopt::Long qw(GetOptions);
my %opts;
GetOptions(
'bug=s' => \$opts{bug},
'msg=s' => \$opts{msg}
) or die "Usage: $0 -bug <bug-id> [-m [edit|<msg>]] <files>\n";
$opts{bug} || die "missing bug";;
my $bug = shift || die "missing bug";; my $url = "https://freeswitch.org/jira/si/jira.issueviews:issue-xml/$opts{bug}/$opts{bug}.xml";
my $url = "https://freeswitch.org/jira/si/jira.issueviews:issue-xml/${bug}/${bug}.xml";
my $cmd; my $cmd;
my $prog = `which curl` || `which wget`; my $prog = `which curl` || `which wget`;
my $auto = 1; my $auto = 1;
@ -28,11 +35,11 @@ my $r = $xs->XMLin($xml);
my $sum = $r->{channel}->{item}->{summary}; my $sum = $r->{channel}->{item}->{summary};
if ($ARGV[0] eq "edit") { if ($opts{msg} eq "edit") {
shift;
$auto = 0; $auto = 0;
open T, ">/tmp/$bug.tmp"; $opts{msg} = undef;
print T "$bug #resolve [$sum]\n\n"; open T, ">/tmp/$opts{bug}.tmp";
print T "$opts{bug} #resolve [$sum]\n\n";
close T; close T;
} }
@ -40,11 +47,17 @@ my $args = join(" ", @ARGV);
my $gitcmd; my $gitcmd;
if ($auto) { if ($auto) {
$gitcmd = "git commit $args -m \"$bug #resolve [$sum]\""; if ($opts{msg}) {
$opts{msg} =~ s/%s/$sum/;
$opts{msg} =~ s/%b/$bug/;
$gitcmd = "git commit $args -m \"$opts{msg}\"";
} else {
$gitcmd = "git commit $args -m \"$opts{bug} #resolve [$sum]\"";
}
} else { } else {
$gitcmd = "git commit $args -t /tmp/$bug.tmp"; $gitcmd = "git commit $args -t /tmp/$opts{bug}.tmp";
} }
system $gitcmd; system $gitcmd;
unlink("/tmp/$bug.tmp"); unlink("/tmp/$opts{bug}.tmp");