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 $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 = {
path => "subject",
ref => $repository->createFileObject($self->subject),
type => "blob",
mode => "100644"
};
push(@tree, $subject);
my $ref = $repository->getReference('refs/heads/issues');
my $root = $ref->getTree();
my $priority = {
path => "priority",
ref => $repository->createFileObject($self->priority),
type => "blob",
mode => "100644"
};
push(@tree, $priority);
my $issueTree = $root->newTree();
my $path = $self->subject;
$path=~s/\s/_/g;
$issueTree->path($self->subject);
my $severity = {
path => "severity",
ref => $repository->createFileObject($self->severity),
type => "blob",
mode => "100644"
};
push(@tree, $severity);
my $subject = $issueTree->newBlob();
$subject->path("subject");
$subject->_content($self->subject);
$issueTree->add($subject);
my $type = {
path => "type",
ref => $repository->createFileObject($self->type),
type => "blob",
mode => "100644"
};
push(@tree, $type);
my $priority = $issueTree->newBlob();
$priority->path("priority");
$priority->_content($self->priority);
$issueTree->add($priority);
my $substatus = {
path => "substatus",
ref => $repository->createFileObject($self->substatus),
type => "blob",
mode => "100644"
};
my $severity = $issueTree->newBlob();
$severity->path("severity");
$severity->_content($self->severity);
$issueTree->add($severity);
my $comment = {
path => "comment",
ref => $repository->createFileObject($self->comment),
type => "blob",
mode => "100644"
};
push(@tree, $comment);
my $type = $issueTree->newBlob();
$type->path("type");
$type->_content($self->type);
$issueTree->add($type);
my $description = {
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)
if (defined($self->substatus) && length($self->substatus) > 0)
{
my $attachments={
path => "attachments",
ref => $self->_createAttachmentTree($repository),
type => "tree",
mode => "040000"
};
push(@tree, $attachments);
my $substatus = $issueTree->newBlob();
$substatus->path("substatus");
$substatus->_content($self->substatus);
$issueTree->add($substatus);
}
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;