FIX: fixed changing issue keys

This commit is contained in:
Dominik Meyer 2018-09-13 21:28:17 +02:00
parent 5f4f7638ca
commit 50e5ccdfe1
No known key found for this signature in database
GPG Key ID: B4C312B600606B64
1 changed files with 129 additions and 20 deletions

View File

@ -188,7 +188,7 @@ sub parseIssue
my $d = shift;
my $tag = shift;
my $status = shift;
my $subject = $d->mypath();
my $subject = $d->find("subject");
my $description = $d->find("description");
my $priority = $d->find("priority");
my $severity = $d->find("severity");
@ -199,7 +199,7 @@ sub parseIssue
my $estimated = $d->find("estimated");
my $working = $d->find("working");
my $tags = $d->find("tags");
my $id = $tag . "-" . substr($d->hash(),0,8);
my $id = $tag . "-" . substr($subject->hash(),0,8);
my $cd = $d->timestamp_added();
my $ld = $d->timestamp_last();
my $author = $d->committer();
@ -212,7 +212,7 @@ sub parseIssue
my $tz=DateTime::TimeZone->new( name => 'local' );
my $issue = Git::IssueManager::Issue->new(subject => $subject);
my $issue = Git::IssueManager::Issue->new(subject => $subject->content);
$issue->status($status);
$issue->description($description->content());
$issue->priority($priority->content());
@ -297,7 +297,8 @@ sub delete
{
if (ref($i) eq "Git::LowLevel::Tree")
{
my $mytag = $tag . "-" . substr($i->hash(),0,8);
my $subject = $i->find("subject");
my $mytag = $tag . "-" . substr($subject->hash(),0,8);
if ($id eq $mytag)
{
$status->del($i);
@ -312,16 +313,20 @@ sub delete
}
=method close
=method changeStatus
set a issue as closed
set status of an issue
=cut
sub close
sub changeStatus
{
my $self = shift;
my $id = shift;
my @statusse = ("open","assigned","inprogress");
my $status= shift;
die("unknown status") unless $status eq "open" || $status eq "closed" || $status eq "inprogress" || $status eq "assigned";
my @statusse = ("open","assigned","inprogress","closed");
die("IssueManager not initialized") unless $self->ready();
my $ref = $self->repository->getReference('refs/heads/issues');
@ -331,27 +336,30 @@ sub close
for my $s (@statusse)
{
for my $status ($root->find($s))
next unless $s ne $status;
for my $stat ($root->find($s))
{
for my $i ($status->get())
for my $i ($stat->get())
{
if (ref($i) eq "Git::LowLevel::Tree")
{
my $mytag = $tag . "-" . substr($i->hash(),0,8);
my $subject = $i->find("subject");
my $mytag = $tag . "-" . substr($subject->hash(),0,8);
if ($id eq $mytag)
{
$status->del($i);
my $issue = $self->parseIssue($i, $tag, "open");
$issue->status("closed");
my $base=$root->find($status);
$stat->del($i);
my $issue = $self->parseIssue($i, $tag, $s);
$issue->status($status);
my $issueTree=$issue->createIssue($self->repository);
my $closed=$root->find("closed");
if (!defined($closed))
if (!defined($base))
{
$closed = $root->newTree();
$closed->path("closed");
$root->add($closed);
$base = $root->newTree();
$base->path($status);
$root->add($base);
}
$closed->add($issueTree);
$base->add($issueTree);
$ref->commit("closed issue " . $i->mypath);
return;
}
@ -362,5 +370,106 @@ sub close
die("issue " . $id . " not found\n");
}
=method assign
assign a worker to an issue
=cut
sub assign
{
my $self = shift;
my $id = shift;
my $worker_name = shift;
my $worker_email = shift;
my $status = "assigned";
my @statusse = ("open","assigned","inprogress","closed");
die("IssueManager not initialized") unless $self->ready();
my $ref = $self->repository->getReference('refs/heads/issues');
my $tag = $ref->find(".tag")->content();
my $root = $ref->getTree();
for my $s (@statusse)
{
next unless $s ne $status;
for my $stat ($root->find($s))
{
for my $i ($stat->get())
{
if (ref($i) eq "Git::LowLevel::Tree")
{
my $subject = $i->find("subject");
my $mytag = $tag . "-" . substr($subject->hash(),0,8);
if ($id eq $mytag)
{
my $base=$root->find($status);
$stat->del($i);
my $issue = $self->parseIssue($i, $tag, $s);
$issue->status($status);
$issue->worker($worker_name);
$issue->worker_email($worker_email);
my $issueTree=$issue->createIssue($self->repository);
if (!defined($base))
{
$base = $root->newTree();
$base->path($status);
$root->add($base);
}
$base->add($issueTree);
$ref->commit("closed issue " . $i->mypath);
return;
}
}
}
}
}
die("issue " . $id . " not found\n");
}
=method close
close an issue
=cut
sub close
{
my $self = shift;
my $id = shift;
$self->changeStatus($id, "closed");
}
=method open
open an issue
=cut
sub open
{
my $self = shift;
my $id = shift;
$self->changeStatus($id, "open");
}
=method start
start an issue
=cut
sub start
{
my $self = shift;
my $id = shift;
$self->changeStatus($id, "inprogress");
}
1;