ADD: close an issue
This commit is contained in:
parent
bec857ca91
commit
62b07b3cc9
@ -414,6 +414,9 @@ sub add
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
=method _to_issue - internal method, do not call directly
|
||||
|
||||
returns the issue converted from a tree hash entry
|
||||
@ -653,4 +656,105 @@ sub delete
|
||||
$self->repository->updateRef("refs/heads/issues",$commit);
|
||||
}
|
||||
|
||||
|
||||
|
||||
=method close
|
||||
|
||||
set the given issue as closed
|
||||
|
||||
=cut
|
||||
sub close
|
||||
{
|
||||
my $self = shift;
|
||||
|
||||
my $id = shift;
|
||||
|
||||
die("no id given") unless defined($id);
|
||||
|
||||
$id=~/^[A-Z]+-(.*)$/;
|
||||
my $hash=$1;
|
||||
|
||||
$self->_load();
|
||||
|
||||
my $found=0;
|
||||
my $index=0;
|
||||
|
||||
# check if issue is already closed
|
||||
for my $i (@{$self->_closed})
|
||||
{
|
||||
if (substr($i->{ref},0,8) eq $hash)
|
||||
{
|
||||
$found=1;
|
||||
last;
|
||||
}
|
||||
$index++;
|
||||
}
|
||||
if ($found)
|
||||
{
|
||||
die("issue is already closed");
|
||||
}
|
||||
|
||||
$index=0;
|
||||
# search for the id in other status arrays
|
||||
for my $i (@{$self->_open})
|
||||
{
|
||||
if (substr($i->{ref},0,8) eq $hash)
|
||||
{
|
||||
$found=1;
|
||||
last;
|
||||
}
|
||||
$index++;
|
||||
}
|
||||
if ($found)
|
||||
{
|
||||
push(@{$self->_closed}, $self->_open()->[$index]);
|
||||
splice @{$self->_open},$index,1;
|
||||
}
|
||||
|
||||
$index=0;
|
||||
|
||||
for my $i (@{$self->_assigned})
|
||||
{
|
||||
if (substr($i->{ref},0,8) eq $hash)
|
||||
{
|
||||
$found=1;
|
||||
last;
|
||||
}
|
||||
$index++;
|
||||
}
|
||||
if ($found)
|
||||
{
|
||||
push(@{$self->_closed}, $self->_assigned()->[$index]);
|
||||
splice @{$self->_assigned},$index,1;
|
||||
}
|
||||
|
||||
$index=0;
|
||||
|
||||
for my $i (@{$self->_inprogress})
|
||||
{
|
||||
if (substr($i->{ref},0,8) eq $hash)
|
||||
{
|
||||
$found=1;
|
||||
last;
|
||||
}
|
||||
$index++;
|
||||
}
|
||||
if ($found)
|
||||
{
|
||||
push(@{$self->_closed}, $self->_inprogress()->[$index]);
|
||||
splice @{$self->_inprogress},$index,1;
|
||||
}
|
||||
|
||||
|
||||
my $roothash = $self->_createTree();
|
||||
|
||||
# commit the issue
|
||||
my $commit=$self->repository->createTreeCommit($roothash,$self->repository->getBranchRef("heads/issues") || "start", "Close: " . $id);
|
||||
|
||||
#now update branch refs/heads/issues
|
||||
$self->repository->updateRef("refs/heads/issues",$commit);
|
||||
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
Loading…
Reference in New Issue
Block a user