Skip to content

Commit

Permalink
Merge pull request #3639 from Mynacol/gitlab-epic
Browse files Browse the repository at this point in the history
[GitlabIssueBridge] Add support for GitLab Epics
  • Loading branch information
Mynacol authored Aug 27, 2023
2 parents 999d5dc + 14607c0 commit 00a18a1
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions bridges/GitlabIssueBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
class GitlabIssueBridge extends BridgeAbstract
{
const MAINTAINER = 'Mynacol';
const NAME = 'Gitlab Issue/Merge Request';
const NAME = 'Gitlab Issue/Merge Request/Epic';
const URI = 'https://gitlab.com/';
const CACHE_TIMEOUT = 1800; // 30min
const DESCRIPTION = 'Returns comments of an issue/MR of a gitlab project';
const DESCRIPTION = 'Returns comments of an issue/MR/Epic of a gitlab project';

const PARAMETERS = [
'global' => [
Expand All @@ -18,12 +18,12 @@ class GitlabIssueBridge extends BridgeAbstract
],
'u' => [
'name' => 'User/Organization name',
'exampleValue' => 'fdroid',
'exampleValue' => 'gitlab-org',
'required' => true
],
'p' => [
'name' => 'Project name',
'exampleValue' => 'fdroidclient',
'exampleValue' => 'gitlab-foss',
'required' => true
]

Expand All @@ -32,15 +32,23 @@ class GitlabIssueBridge extends BridgeAbstract
'i' => [
'name' => 'Issue number',
'type' => 'number',
'exampleValue' => '2099',
'exampleValue' => '1',
'required' => true
]
],
'Merge Request comments' => [
'i' => [
'name' => 'Merge Request number',
'type' => 'number',
'exampleValue' => '2099',
'exampleValue' => '1',
'required' => true
]
],
'Epic comments' => [
'i' => [
'name' => 'Epic number',
'type' => 'number',
'exampleValue' => '1',
'required' => true
]
]
Expand All @@ -56,6 +64,9 @@ public function getName()
case 'Merge Request comments':
$name .= ' MR !' . $this->getInput('i');
break;
case 'Epic comments':
$name .= ' Epic &' . $this->getInput('i');
break;
default:
return parent::getName();
}
Expand All @@ -74,6 +85,9 @@ public function getURI()
case 'Merge Request comments':
$uri .= '-/merge_requests';
break;
case 'Epic comments':
$uri = 'https://' . $host . '/groups/' . $this->getInput('u') . '/-/epics';
break;
default:
return $uri;
}
Expand Down Expand Up @@ -107,8 +121,10 @@ public function collectData()
foreach ($comments as $value) {
foreach ($value->notes as $comment) {
$item = [];
$item['uri'] = $comment->noteable_note_url;
$item['uid'] = $item['uri'];
if ($comment->noteable_note_url !== null) {
$item['uri'] = $comment->noteable_note_url;
$item['uid'] = $item['uri'];
}

// TODO fix invalid timestamps (fdroid bot)
$item['timestamp'] = $comment->created_at ?? $comment->updated_at ?? $comment->last_edited_at;
Expand Down

0 comments on commit 00a18a1

Please sign in to comment.