From 99d29ba6792de574666b698a7a67515d9b97d5f7 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 19 Aug 2015 13:09:33 -0500 Subject: [PATCH] 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 --- support-d/utils/filebug.pl | 60 ++++++++++++++++++++------------------ support-d/utils/fixbug.pl | 28 ++++++++++++++---- 2 files changed, 54 insertions(+), 34 deletions(-) diff --git a/support-d/utils/filebug.pl b/support-d/utils/filebug.pl index d8b28e9b71..18a8135984 100755 --- a/support-d/utils/filebug.pl +++ b/support-d/utils/filebug.pl @@ -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 -desc ....\n"; + 'debug' => \$opts{debug}, + ) or die "Usage: $0 -summary -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}; +} diff --git a/support-d/utils/fixbug.pl b/support-d/utils/fixbug.pl index a445871806..3e82dda01d 100755 --- a/support-d/utils/fixbug.pl +++ b/support-d/utils/fixbug.pl @@ -8,11 +8,15 @@ my %opts; GetOptions( 'bug=s' => \$opts{bug}, - 'msg=s' => \$opts{msg} - ) or die "Usage: $0 -bug [-m [edit|]] \n"; + 'msg=s' => \$opts{msg}, + 'debug' => \$opts{debug}, + 'append=s' => \$opts{append}, + 'comment=s' => \$opts{comment} + ) or die "Usage: $0 -bug [-m [edit|]] [-append ] [-debug] \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");