ADD: method to close an issue
This commit is contained in:
parent
cad6c3276a
commit
5f4f7638ca
@ -311,4 +311,56 @@ sub delete
|
||||
die("issue " . $id . " not found\n");
|
||||
}
|
||||
|
||||
|
||||
=method close
|
||||
|
||||
set a issue as closed
|
||||
|
||||
=cut
|
||||
sub close
|
||||
{
|
||||
my $self = shift;
|
||||
my $id = shift;
|
||||
my @statusse = ("open","assigned","inprogress");
|
||||
|
||||
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 $status ($root->find($s))
|
||||
{
|
||||
for my $i ($status->get())
|
||||
{
|
||||
if (ref($i) eq "Git::LowLevel::Tree")
|
||||
{
|
||||
my $mytag = $tag . "-" . substr($i->hash(),0,8);
|
||||
if ($id eq $mytag)
|
||||
{
|
||||
$status->del($i);
|
||||
my $issue = $self->parseIssue($i, $tag, "open");
|
||||
$issue->status("closed");
|
||||
my $issueTree=$issue->createIssue($self->repository);
|
||||
my $closed=$root->find("closed");
|
||||
if (!defined($closed))
|
||||
{
|
||||
$closed = $root->newTree();
|
||||
$closed->path("closed");
|
||||
$root->add($closed);
|
||||
}
|
||||
$closed->add($issueTree);
|
||||
$ref->commit("closed issue " . $i->mypath);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
die("issue " . $id . " not found\n");
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
Loading…
Reference in New Issue
Block a user