ADD: support close commit id when closing issue

This commit is contained in:
Dominik Meyer 2018-09-16 00:06:52 +02:00
parent 2ba0b590d9
commit ca6b2aed9e
No known key found for this signature in database
GPG Key ID: B4C312B600606B64

View File

@ -6,6 +6,7 @@ use DateTime;
use DateTime::TimeZone;
use Data::Dumper;
use Git::LowLevel;
use Git::IssueManager::Issue;
=head1 DESCRIPTION
@ -569,10 +570,54 @@ sub assign
=cut
sub close
{
my $self = shift;
my $id = shift;
my $self = shift;
my $id = shift;
my $commit = shift || "";
my $status = "closed";
my @statusse = ("open","assigned","inprogress","closed");
$self->changeStatus($id, "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->close_commit($commit);
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 open