ADD: first version for listing and adding issues
This commit is contained in:
parent
5fbb5a4baa
commit
9d1814c16b
9
bin/git-issue
Normal file
9
bin/git-issue
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#!perl
|
||||||
|
# ABSTRACT: subcommand to git for issue management
|
||||||
|
# PODNAME: git-issue
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use Try::Tiny;
|
||||||
|
use App::Git::IssueManager;
|
||||||
|
|
||||||
|
App::Git::IssueManager->new_with_command()->run;
|
@ -1,6 +1,19 @@
|
|||||||
package App::Git::IssueManager;
|
package App::Git::IssueManager;
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
use Moose;
|
||||||
|
use MooseX::App qw(Color BashCompletion);
|
||||||
|
|
||||||
|
# the version of the module
|
||||||
|
our $VERSION = '0.1';
|
||||||
|
|
||||||
|
|
||||||
|
=head1 DESCRIPTION
|
||||||
|
|
||||||
|
GIT IssueManager
|
||||||
|
|
||||||
|
Manages issues within your repository using a "issues" branch.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
85
lib/App/Git/IssueManager/Add.pm
Normal file
85
lib/App/Git/IssueManager/Add.pm
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
package App::Git::IssueManager::Add;
|
||||||
|
#ABSTRACT: class implementing the add issue command of the GIT IssueManager
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use MooseX::App::Command;
|
||||||
|
extends qw(App::Git::IssueManager);
|
||||||
|
use Git::RepositoryHL;
|
||||||
|
use Git::IssueManager;
|
||||||
|
use Git::IssueManager::Issue;
|
||||||
|
use App::Git::IssueManager::Config;
|
||||||
|
use File::Temp qw/ tempfile/;
|
||||||
|
use File::Slurp;
|
||||||
|
use Term::ANSIColor;
|
||||||
|
use Try::Tiny;
|
||||||
|
|
||||||
|
|
||||||
|
command_short_description 'create an issue within a project';
|
||||||
|
command_usage 'git issue add -s Humbug';
|
||||||
|
|
||||||
|
option 'subject' => (
|
||||||
|
is => 'ro',
|
||||||
|
isa => 'Str',
|
||||||
|
required => 1,
|
||||||
|
documentation => q[the subject/title of the issue],
|
||||||
|
cmd_aliases => [qw(s)]
|
||||||
|
);
|
||||||
|
|
||||||
|
option 'priority' => (
|
||||||
|
is => 'ro',
|
||||||
|
isa => 'Str',
|
||||||
|
required => 0,
|
||||||
|
documentation => q[the priority of the issue (low, medium, high, urgent)],
|
||||||
|
cmd_aliases => [qw(p)],
|
||||||
|
default => "low"
|
||||||
|
);
|
||||||
|
|
||||||
|
option 'severity' => (
|
||||||
|
is => 'ro',
|
||||||
|
isa => 'Str',
|
||||||
|
required => 0,
|
||||||
|
documentation => q[the severity of the issue (low, medium, high, critical)],
|
||||||
|
cmd_aliases => [qw(e)],
|
||||||
|
default => "low"
|
||||||
|
);
|
||||||
|
|
||||||
|
option 'type' => (
|
||||||
|
is => 'ro',
|
||||||
|
isa => 'Str',
|
||||||
|
required => 0,
|
||||||
|
documentation => q[the type of the issue (bug, security-bug, improvement, feature, task)],
|
||||||
|
cmd_aliases => [qw(t)],
|
||||||
|
default => "bug"
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
sub run
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
my $manager = Git::IssueManager->new(repository=>Git::RepositoryHL->new(git_dir=> "."));
|
||||||
|
if (!$manager->ready)
|
||||||
|
{
|
||||||
|
print("IssueManager not initialized yet. Please call \"init\" command to do so.");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
my ($fh, $filename) = tempfile();
|
||||||
|
close($fh);
|
||||||
|
|
||||||
|
my $config=App::Git::IssueManager::Config->new(confname => 'config');
|
||||||
|
my $editor = $config->get(key=>"core.editor") || ENV{'EDITOR'} || "vim";
|
||||||
|
|
||||||
|
system($editor . " " .$filename);
|
||||||
|
|
||||||
|
my $text = read_file($filename);
|
||||||
|
|
||||||
|
my $issue = Git::IssueManager::Issue->new(subject => $self->subject);
|
||||||
|
$issue->description($text);
|
||||||
|
$issue->priority($self->priority);
|
||||||
|
$issue->severity($self->severity);
|
||||||
|
$issue->type($self->type);
|
||||||
|
$manager->add($issue);
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
30
lib/App/Git/IssueManager/Config.pm
Normal file
30
lib/App/Git/IssueManager/Config.pm
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package App::Git::IssueManager::Config;
|
||||||
|
#ABSTRACT: Class for using gits configuration file for the IssueManager App
|
||||||
|
use Moose;
|
||||||
|
extends 'Config::GitLike';
|
||||||
|
use Config::GitLike;
|
||||||
|
|
||||||
|
sub dir_file
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
|
||||||
|
return "config";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub global_file
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub user_file
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
|
||||||
|
return "~/.gitconfig";
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
60
lib/App/Git/IssueManager/Get.pm
Normal file
60
lib/App/Git/IssueManager/Get.pm
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
package App::Git::IssueManager::Get;
|
||||||
|
#ABSTRACT: class implementing the get issue command of the GIT IssueManager
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use MooseX::App::Command;
|
||||||
|
extends qw(App::Git::IssueManager);
|
||||||
|
use Git::RepositoryHL;
|
||||||
|
use Git::IssueManager;
|
||||||
|
use Git::IssueManager::Issue;
|
||||||
|
|
||||||
|
use Term::ANSIColor;
|
||||||
|
use Try::Tiny;
|
||||||
|
|
||||||
|
|
||||||
|
command_short_description 'get an issue of a repository identified by the given id';
|
||||||
|
command_usage 'git issue get -i TST-a34df432';
|
||||||
|
|
||||||
|
option 'id' => (
|
||||||
|
is => 'ro',
|
||||||
|
isa => 'Str',
|
||||||
|
required => 1,
|
||||||
|
documentation => q[the id of the issue],
|
||||||
|
cmd_aliases => [qw(i)]
|
||||||
|
);
|
||||||
|
|
||||||
|
sub run
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
my $manager = Git::IssueManager->new(repository=>Git::RepositoryHL->new(git_dir=> "."));
|
||||||
|
if (!$manager->ready)
|
||||||
|
{
|
||||||
|
print("IssueManager not initialized yet. Please call \"init\" command to do so.");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
my $issue=$manager->get($self->id);
|
||||||
|
|
||||||
|
printf("%20s: %30s\n", "ID", $issue->id);
|
||||||
|
printf("%20s: %30s\n", "Subject", $issue->subject);
|
||||||
|
printf("%20s: %30s\n", "Type", $issue->type);
|
||||||
|
printf("%20s: %30s\n", "Priority", $issue->priority);
|
||||||
|
printf("%20s: %30s\n", "Severity", $issue->severity);
|
||||||
|
printf("%20s: %30s\n", "Creation Date", $issue->creation_date()->ymd()." ".$issue->creation_date->hms());
|
||||||
|
printf("%20s: %30s\n", "Author", $issue->author);
|
||||||
|
printf("%20s: %30s\n", "Author Email", $issue->author_email);
|
||||||
|
printf("%20s: %30s\n", "Status", $issue->status);
|
||||||
|
if ($issue->status eq "closed")
|
||||||
|
{
|
||||||
|
printf("%20s: %30s\n", "Closed Date", $issue->closed_date()->ymd()." ".$issue->closed_date->hms());
|
||||||
|
}
|
||||||
|
printf("%20s: %30s\n", "Substatus", $issue->substatus);
|
||||||
|
printf("%20s: %30s\n", "Comment", $issue->comment);
|
||||||
|
printf("%20s: %30s\n", "Tags", join(",", @{$issue->tags}));
|
||||||
|
printf("%20s: %30s\n", "Assignee", $issue->worker);
|
||||||
|
printf("%20s: %30s\n", "Assignee Email", $issue->worker_email);
|
||||||
|
printf("%20s: %30s\n", "Last Change Date", $issue->last_change_date()->ymd()." ".$issue->last_change_date->hms());
|
||||||
|
printf("%20s: \n %s\n", "Description",$issue->description);
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
43
lib/App/Git/IssueManager/Init.pm
Normal file
43
lib/App/Git/IssueManager/Init.pm
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
package App::Git::IssueManager::Init;
|
||||||
|
#ABSTRACT: class implementing the init command of the GIT IssueManager
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use MooseX::App::Command;
|
||||||
|
extends qw(App::Git::IssueManager);
|
||||||
|
use Git::RepositoryHL;
|
||||||
|
use Git::IssueManager;
|
||||||
|
use Git::IssueManager::Issue;
|
||||||
|
|
||||||
|
use Term::ANSIColor;
|
||||||
|
use Try::Tiny;
|
||||||
|
|
||||||
|
|
||||||
|
command_short_description 'initialize IssueManager in the current git repository';
|
||||||
|
command_usage 'git issue init -t TST';
|
||||||
|
|
||||||
|
option 'tag' => (
|
||||||
|
is => 'ro',
|
||||||
|
isa => 'Str',
|
||||||
|
required => 1,
|
||||||
|
documentation => q[the tag to prepend in front of issue ids (eg. TST-ab5436fe, TST is the tag)],
|
||||||
|
cmd_aliases => [qw(t)]
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
sub run
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
|
||||||
|
my $manager = Git::IssueManager->new(repository=>Git::RepositoryHL->new(git_dir=> "."));
|
||||||
|
if (!$manager->ready)
|
||||||
|
{
|
||||||
|
$manager->init($self->tag);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
die("IssueManager already initialized");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
61
lib/App/Git/IssueManager/List.pm
Normal file
61
lib/App/Git/IssueManager/List.pm
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
package App::Git::IssueManager::List;
|
||||||
|
#ABSTRACT: class implementing the add issue command of the GIT IssueManager
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use MooseX::App::Command;
|
||||||
|
extends qw(App::Git::IssueManager);
|
||||||
|
use Git::RepositoryHL;
|
||||||
|
use Git::IssueManager;
|
||||||
|
use Git::IssueManager::Issue;
|
||||||
|
|
||||||
|
use Term::ANSIColor;
|
||||||
|
use Try::Tiny;
|
||||||
|
|
||||||
|
|
||||||
|
command_short_description 'list issues of a repository';
|
||||||
|
command_usage 'git issue list';
|
||||||
|
|
||||||
|
|
||||||
|
option 'use_color' => (
|
||||||
|
is => 'ro',
|
||||||
|
isa => 'Bool',
|
||||||
|
required => 0,
|
||||||
|
documentation => q[use anso color to highlight critical issues],
|
||||||
|
cmd_aliases => [qw(color)],
|
||||||
|
default => 1
|
||||||
|
);
|
||||||
|
|
||||||
|
sub run
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
my $manager = Git::IssueManager->new(repository=>Git::RepositoryHL->new(git_dir=> "."));
|
||||||
|
if (!$manager->ready)
|
||||||
|
{
|
||||||
|
print("IssueManager not initialized yet. Please call \"init\" command to do so.");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
my @issues=$manager->list();
|
||||||
|
print color('reset');
|
||||||
|
|
||||||
|
for my $i (@issues)
|
||||||
|
{
|
||||||
|
if ($self->use_color && ($i->priority eq "high" || $i->priority eq "urgent" || $i->severity eq "hight" || $i->severity eq "critical"))
|
||||||
|
{
|
||||||
|
print color('bold red');
|
||||||
|
}
|
||||||
|
elsif ($self->use_color && ($i->priority eq "medium" || $i->severity eq "medium"))
|
||||||
|
{
|
||||||
|
print color('bold yellow');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print color('reset');
|
||||||
|
}
|
||||||
|
printf("%20s\t%15s\t%50s\t%10s\t%10s\t%20s\n", $i->id, $i->type, $i->subject, $i->priority, $i->severity,
|
||||||
|
$i->creation_date->ymd() . " " . $i->creation_date->hms());
|
||||||
|
}
|
||||||
|
print color('reset');
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
Loading…
Reference in New Issue
Block a user