diff --git a/lib/Git/IssueManager.pm b/lib/Git/IssueManager.pm index c61c393..2108205 100644 --- a/lib/Git/IssueManager.pm +++ b/lib/Git/IssueManager.pm @@ -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;