BugCli
view release on metacpan or search on metacpan
qw(assigned_to bug_severity bug_status creation_ts short_desc product_id reporter version target_milestone component_id)
],
'values' => [
$login_to_uid{$assignee}, $severity,
$time, $subject,
$config->{product}->{product_id}, $login_to_uid{$llogin},
$version, $milestone,
$config->{product}->{component_id}
]
);
my ($bugid) = $dbh->fetch_one_value( sql => $Query{AutoIncrement} );
update_bug( $dbh, $bugid, undef, undef, $text );
return $bugid;
}
sub update_bug {
my ( $dbh, $bug_id, $bug_resolution, $bug_status, $text ) = @_;
if ( defined $bug_resolution ) {
$dbh->do_update(
'table' => 'bugs',
'values' => { resolution => "'$bug_resolution'" },
'criteria' => { bug_id => $bug_id }
);
Severity: $$bug{bug_severity}
Status: $$bug{bug_status}
Resolution: $$bug{resolution}
Comments:
$$bug{COMMENTS}
=====================
EOT
}
sub get_comments {
my ( $dbh, $bugid ) = @_;
my ($text);
my ($bth) = $dbh->fetch_select(
table => 'longdescs',
criteria => { bug_id => $bugid },
columns => [qw(who bug_when thetext)]
);
foreach my $z ( @{$bth} ) {
next if not defined $$z{thetext} or
$$z{thetext} =~ /^\n$/ or
$$z{thetext} =~ /^\s*(:?done|fixed|\.)\s*$/i;
$text .= "\n-------------------\n";
$text .= "From: $uid_to_login{$$z{who}} When: $$z{bug_when}\n";
$text .= $$z{thetext};
getopts('fo:',\%opts);
@ARGV = @ta;
my($sql) = "SELECT * FROM bugs WHERE (lastdiffed > '" . range_to_date($date) . "' AND assigned_to = $login_to_uid{$llogin} AND resolution = 'FIXED')";
my(%bugz) = query_to_bugs( $dbh->fetch_select(sql=>$sql ) );
$fh = new FileHandle;
if($opts{o}){
$fh->open("> $opts{o}");
}else{
$fh->open(">&STDOUT");
}
foreach my $bugid (sort keys %bugz) {
print $fh "[BUG #$bugid] $bugz{$bugid}{short_desc}\n";
if($opts{f}){
print $fh "$bugz{$bugid}{COMMENTS}\n";
}
}
print "Output written to $opts{o} \n" if $opts{o};
$fh->close;
}
sub range_to_date {
my($scale) = @_;
# general format: "[d<day-of-mont/day-of-week>][w<week-of-year>][m<month>][y<year>]
}
}
# }}}
# show command declarations {{{
sub run_show {
my ( $self, $comm ) = @_;
my (@bugids);
if ( $comm =~ /^\d+$/ ) { #ok. just show by bugid
push @bugids, $comm;
}
elsif ( $comm =~ m#^/(.*)/$# ) { #ok, got regexp. let's find em!
my ($r) = $1;
my (%a) = query_to_bugs(
$dbh->fetch_select(
sql => "SELECT bug_id FROM bugs where short_desc REGEXP '$1'"
)
);
push @bugids, keys %a;
}
else {
print "Whoopsie! Bad syntax. See 'help show' for explainations.\n";
return;
}
foreach my $bugid (@bugids) {
my (%b) = query_to_bugs(
$dbh->fetch_select(
table => 'bugs',
criteria => { 'bug_id' => $bugid }
)
);
$self->page( print_bug( $bugid, $b{$bugid} ) );
print "Press any key to continue...";
getc;
}
}
sub run_take {
push @_, undef if scalar(@_) < 3;
do_fix( @_, undef, undef, undef, 'take' );
}
do_fix( @_, undef, undef, undef, 'comment' );
}
sub run_fix {
push @_, undef if scalar(@_) < 3;
do_fix( @_, undef, undef, undef, 'fix' );
}
sub do_fix {
my ( $self, $bugid, $text, undef, undef, undef, $cmd ) = @_;
if ( defined $bugid && $bugid =~ /^\d+/ ) {
my (%b) = query_to_bugs(
$dbh->fetch_select(
table => 'bugs',
criteria => { 'bug_id' => $bugid }
)
);
print "No such bug!\n", return if not keys %b;
if ( not defined $text ) {
print "Please enter a comment: (Ctrl-D to finish) \n";
$text = join '', <STDIN>;
}
print "You should enter some comments!", return if $text eq '';
if ( $cmd eq 'fix') {
update_bug( $dbh, $bugid, 'FIXED', 'RESOLVED', $text );
}
elsif ( $cmd eq 'comment' ) {
update_bug( $dbh, $bugid, undef, undef, $text );
}
elsif ( $cmd eq 'take' ) {
update_bug( $dbh, $bugid, undef, 'ASSIGNED', $text );
}
}
else {
print "Incorrect syntax! Read 'help fix'. \n";
}
}
# }}}
BugCli/Completions.pm view on Meta::CPAN
package BugCli::Completions;
push @BugCli::ISA, __PACKAGE__
unless grep { $_ eq __PACKAGE__ } @BugCli::ISA;
sub last_bugids { return keys %BugCli::lastbugs; }
sub comp_delete { last_bugids }
sub comp_show { last_bugids; }
sub comp_fix { last_bugids; }
sub comp_bugs { return keys %{ $BugCli::config->{query} }; }
sub comp_config {
my ( $self, $param ) = @_;
if ( not $param ) {
return ( keys %{$BugCli::config}, 'show' );
}
elsif ( $param =~ /(.*?)\.(.*)?$/ ) {
if ( exists $BugCli::config->{$1} ) {
my ($a) = $2 || ".*";
( run in 1.171 second using v1.01-cache-2.11-cpan-5735350b133 )