ADD: added method to modify an issue

GIM-61e769c5: #close
This commit is contained in:
Dominik Meyer 2018-09-16 23:05:47 +02:00
parent 3b6b77ef52
commit 63f79884eb
No known key found for this signature in database
GPG Key ID: B4C312B600606B64

View File

@ -764,4 +764,81 @@ sub get
die("issue " . $id . " not found\n");
}
=method modify
modify an existing issues
@param 1. parameter = issue id
@param 2. parameter = modification hash
support keys subject, description, priority, severity, type
=cut
sub modify
{
my $self = shift;
my $id = shift;
my $modifications = shift;
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)
{
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)
{
$stat->del($i);
my $issue = $self->parseIssue($i, $tag, $s);
# modify the issue
if (defined($modifications->{subject}))
{
$issue->subject($modifications->{subject});
}
if (defined($modifications->{description}))
{
$issue->description($modifications->{description});
}
if (defined($modifications->{priority}))
{
$issue->priority($modifications->{priority});
}
if (defined($modifications->{severity}))
{
$issue->severity($modifications->{severity});
}
if (defined($modifications->{type}))
{
$issue->type($modifications->{type});
}
my $issueTree=$issue->createIssue($self->repository);
$stat->add($issueTree);
$ref->commit("modified issue " . $i->mypath);
return;
}
}
}
}
}
die("issue " . $id . " not found\n");
}
1;