FS-7988 FS-7989 add debug mode to fixbug and filebug and add -project to filebug and add -append and -comment to fixbug to append to defualt commit msg

This commit is contained in:
Anthony Minessale 2015-08-19 13:09:33 -05:00
parent 25e8d05492
commit 99d29ba679
2 changed files with 54 additions and 34 deletions

View File

@ -39,6 +39,7 @@ my $hashtxt = `git log -1 --oneline 2>/dev/null`;
my ($hash) = split(" ", $hashtxt);
GetOptions(
'project=s' => \$opts{project},
'summary=s' => \$opts{summary},
'desc=s' => \$opts{desc},
'components=s' => \$opts{components},
@ -46,9 +47,12 @@ GetOptions(
'user=s' => \$opts{user},
'pass=s' => \$opts{pass},
'type=s' => \$opts{type},
) or die "Usage: $0 -summary <summary> -desc <desc> ....\n";
'debug' => \$opts{debug},
) or die "Usage: $0 -summary <summary> -desc <desc> [-debug] ....\n";
$opts{project} or $opts{project} = "FS";
if ($opts{components}) {
$opts{components_array} = [map {{name => $_}} split(" ", $opts{components})];
} else {
@ -63,12 +67,18 @@ if (!$opts{user}) {
$opts{user} = getuser();
}
if (!$opts{pass}) {
if (!$opts{pass} && !$opts{debug}) {
$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:";
my $jira;
my $issue;
if (!$opts{debug}) {
$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:";
}
#print $issue->{key};
#exit;
@ -96,29 +106,23 @@ if (!$opts{hash}) {
}
}
my $input = {
fields => {
project => { key => $opts{project} },
issuetype => { name => $opts{type} },
summary => $opts{summary},
description => $opts{desc},
customfield_10024 => $opts{hash},
customfield_10025 => $opts{hash},
components => $opts{components_array}
},
};
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}
},
}) or die "Issue was not created:";
print "Issue Posted: " . $issue->{key};
__END__
my $jira = JIRA::REST->new('https://freeswitch.org/jira', $user, $pass);
#$issue = $jira->GET("/issue/FS-7985");
#print Dumper $issue;
if ($opts{debug}) {
print Dumper \%opts;
print Dumper $input;
} else {
$issue = $jira->POST('/issue', undef, $input) or die "Issue was not created:";
print "Issue Posted: " . $issue->{key};
}

View File

@ -8,11 +8,15 @@ my %opts;
GetOptions(
'bug=s' => \$opts{bug},
'msg=s' => \$opts{msg}
) or die "Usage: $0 -bug <bug-id> [-m [edit|<msg>]] <files>\n";
'msg=s' => \$opts{msg},
'debug' => \$opts{debug},
'append=s' => \$opts{append},
'comment=s' => \$opts{comment}
) or die "Usage: $0 -bug <bug-id> [-m [edit|<msg>]] [-append <msg>] [-debug] <files>\n";
$opts{bug} || die "missing bug";;
$opts{bug} or $opts{bug} = shift;
my $url = "https://freeswitch.org/jira/si/jira.issueviews:issue-xml/$opts{bug}/$opts{bug}.xml";
my $cmd;
my $prog = `which curl` || `which wget`;
@ -46,18 +50,30 @@ if ($opts{msg} eq "edit") {
my $args = join(" ", @ARGV);
my $gitcmd;
if ($opts{append}) {
$opts{append} = " " . $opts{append};
}
if ($opts{comment}) {
$opts{append} .= " #comment " . $opts{comment};
}
if ($auto) {
if ($opts{msg}) {
$opts{msg} =~ s/%s/$sum/;
$opts{msg} =~ s/%b/$opts{bug}/;
$gitcmd = "git commit $args -m \"$opts{msg}\"";
$gitcmd = "git commit $args -m \"$opts{msg}$opts{append}\"";
} else {
$gitcmd = "git commit $args -m \"$opts{bug} #resolve [$sum]\"";
$gitcmd = "git commit $args -m \"$opts{bug} #resolve [$sum]$opts{append}\"";
}
} else {
$gitcmd = "git commit $args -t /tmp/$opts{bug}.tmp";
}
system $gitcmd;
if ($opts{debug}) {
print "CMD: $gitcmd\n";
} else {
system $gitcmd;
}
unlink("/tmp/$opts{bug}.tmp");