ADD: improved issue saving

This commit is contained in:
Dominik Meyer 2018-09-10 22:41:23 +02:00
parent 62b07b3cc9
commit 994fa9818b
No known key found for this signature in database
GPG Key ID: B4C312B600606B64

View File

@ -462,109 +462,89 @@ sub createIssue
{ {
my $self = shift; my $self = shift;
my $repository = shift; my $repository = shift;
my @tree;
die("No Git::RepositoryHL object given") unless ref($repository) eq "Git::RepositoryHL"; die("No Git::LowLevel object given") unless ref($repository) eq "Git::LowLevel";
my $subject = { my $ref = $repository->getReference('refs/heads/issues');
path => "subject", my $root = $ref->getTree();
ref => $repository->createFileObject($self->subject),
type => "blob",
mode => "100644"
};
push(@tree, $subject);
my $priority = { my $issueTree = $root->newTree();
path => "priority", my $path = $self->subject;
ref => $repository->createFileObject($self->priority), $path=~s/\s/_/g;
type => "blob", $issueTree->path($self->subject);
mode => "100644"
};
push(@tree, $priority);
my $severity = { my $subject = $issueTree->newBlob();
path => "severity", $subject->path("subject");
ref => $repository->createFileObject($self->severity), $subject->_content($self->subject);
type => "blob", $issueTree->add($subject);
mode => "100644"
};
push(@tree, $severity);
my $type = { my $priority = $issueTree->newBlob();
path => "type", $priority->path("priority");
ref => $repository->createFileObject($self->type), $priority->_content($self->priority);
type => "blob", $issueTree->add($priority);
mode => "100644"
};
push(@tree, $type);
my $substatus = { my $severity = $issueTree->newBlob();
path => "substatus", $severity->path("severity");
ref => $repository->createFileObject($self->substatus), $severity->_content($self->severity);
type => "blob", $issueTree->add($severity);
mode => "100644"
};
my $comment = { my $type = $issueTree->newBlob();
path => "comment", $type->path("type");
ref => $repository->createFileObject($self->comment), $type->_content($self->type);
type => "blob", $issueTree->add($type);
mode => "100644"
};
push(@tree, $comment);
my $description = { if (defined($self->substatus) && length($self->substatus) > 0)
path => "description",
ref => $repository->createFileObject($self->description),
type => "blob",
mode => "100644"
};
push(@tree, $description);
my $worker = {
path => "worker",
ref => $repository->createFileObject($self->worker . "<" . $self->worker_email . ">"),
type => "blob",
mode => "100644"
};
push(@tree, $worker);
my $estimated = {
path => "estimated",
ref => $repository->createFileObject($self->estimated_time),
type => "blob",
mode => "100644"
};
push(@tree, $estimated);
my $working_time = {
path => "working",
ref => $repository->createFileObject($self->working_time),
type => "blob",
mode => "100644"
};
push(@tree, $working_time);
my $tags = {
path => "tags",
ref => $repository->createFileObject(join "\n", @{$self->tags}),
type => "blob",
mode => "100644"
};
push(@tree, $tags);
if (@{$self->attachements} > 0)
{ {
my $attachments={ my $substatus = $issueTree->newBlob();
path => "attachments", $substatus->path("substatus");
ref => $self->_createAttachmentTree($repository), $substatus->_content($self->substatus);
type => "tree", $issueTree->add($substatus);
mode => "040000"
};
push(@tree, $attachments);
} }
return $repository->createTree(\@tree); if (defined($self->comment) && length($self->comment)> 0)
{
my $comment = $issueTree->newBlob();
$comment->path("comment");
$comment->_content($self->comment);
$issueTree->add($comment);
}
if (defined($self->description) && length($self->description)> 0)
{
my $description = $issueTree->newBlob();
$description->path("description");
$description->_content($self->description);
$issueTree->add($description);
}
if (defined($self->worker) && length($self->worker)> 0)
{
my $worker = $issueTree->newBlob();
$worker->path("worker");
$worker->_content($self->worker . "<" . $self->worker_email . ">");
$issueTree->add($worker);
}
my $estimated = $issueTree->newBlob();
$estimated->path("estimated");
$estimated->_content($self->estimated_time);
$issueTree->add($estimated);
my $working_time = $issueTree->newBlob();
$working_time->path("working");
$working_time->_content($self->working_time);
$issueTree->add($working_time);
if (defined($self->tags) && @{$self->tags}> 0)
{
my $tags = $issueTree->newBlob();
$tags->path("tags");
$tags->_content(join "\n", @{$self->tags});
$issueTree->add($tags);
}
return $issueTree;
} }
1; 1;