Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Trac2Gitlab
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stud.IP
Plugins
Trac2Gitlab
Merge requests
!5
show open merge requests
Code
Review changes
Check out branch
Open in Workspace
Download
Patches
Plain diff
Expand sidebar
Merged
show open merge requests
mr
into
main
Overview
0
Commits
2
Pipelines
0
Changes
4
Merged
show open merge requests
Jan-Hendrik Willms
requested to merge
mr
into
main
Feb 24, 2022
Overview
0
Commits
2
Pipelines
0
Changes
4
0
0
Merge request reports
Compare
main
version 1
8796604b
Feb 24, 2022
main (base)
and
latest version
latest version
8698d1cf
2 commits,
Feb 24, 2022
version 1
8796604b
3 commits,
Feb 24, 2022
4 files
+
176
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
4
controllers/mergerequests.php
0 → 100644
+
112
−
0
View file @ 8698d1cf
Edit in single-file editor
Open in Web IDE
<?php
final
class
MergerequestsController
extends
TracToGitlab\GitlabController
{
public
function
before_filter
(
&
$action
,
&
$args
)
{
parent
::
before_filter
(
$action
,
$args
);
PageLayout
::
setTitle
(
_
(
'Merge Requests'
));
$this
->
activateNavigation
(
'merge-requests'
);
}
public
function
index_action
()
{
$data
=
$this
->
readFromCache
(
'merge-requests'
,
true
);
if
(
$data
===
false
)
{
$this
->
mrs
=
$this
->
fetchMergeRequests
();
$this
->
writeToCache
(
'merge-requests'
,
$this
->
issues
);
}
else
{
$this
->
mrs
=
$data
[
'data'
];
Sidebar
::
get
()
->
addWidget
(
new
TemplateWidget
(
'Aus dem Cache'
,
$this
->
get_template_factory
()
->
open
(
$this
->
get_default_template
(
'sidebar'
)
),
[
'time'
=>
$data
[
'time'
]]
));
}
}
public
function
diff_action
(
$mr_iid
)
{
// $versions = $this->gitlab->mergeRequests()->
}
private
function
fetchMergeRequests
():
array
{
$mrs
=
$this
->
gitlabPager
->
fetchAll
(
$this
->
gitlab
->
mergeRequests
(),
'all'
,
[
$this
->
gitlabProjectId
,
[
'sort'
=>
'asc'
,
'scope'
=>
'all'
,
'state'
=>
'opened'
,
]
]
);
$mrs
=
array_filter
(
$mrs
,
function
(
$mr
)
{
if
(
$mr
[
'draft'
]
||
$mr
[
'work_in_progress'
]
||
$mr
[
'merge_when_pipeline_succeeds'
])
{
return
false
;
}
return
true
;
// foreach (['worksforme', 'wontfix', 'Duplicate', 'invalid'] as $label) {
// if (in_array($label, $issue['labels'])) {
// return false;
// }
// }
//
// $has_version = array_reduce($issue['labels'], function ($has_version, $label) {
// return $has_version || strpos($label, 'Version::') === 0;
// }, false);
// return $has_version;
});
// var_dump($mrs);die;
//
// $issues = array_map(function ($issue) {
// $issue['studip_version'] = $this->extractVersion($issue['labels']);
// $issue['mr'] = $this->fetchRelatedMergeRequest($issue['iid']);
// return $issue;
// }, $issues);
//
usort
(
$mrs
,
function
(
$a
,
$b
)
{
return
strcmp
(
$b
[
'updated_at'
],
$a
[
'updated_at'
]);
});
return
$mrs
;
}
private
function
fetchRelatedMergeRequest
(
int
$issue_id
)
{
$mrs
=
$this
->
gitlab
->
issues
()
->
closedByMergeRequests
(
$this
->
gitlabProjectId
,
$issue_id
);
foreach
(
$mrs
as
$mr
)
{
if
(
$mr
[
'state'
]
===
'merged'
)
{
return
$mr
[
'iid'
];
}
}
return
null
;
}
private
function
extractVersion
(
array
$labels
):
string
{
$version
=
''
;
foreach
(
$labels
as
$label
)
{
if
(
strpos
(
$label
,
'Version::'
)
===
0
)
{
$v
=
substr
(
$label
,
9
);
if
(
!
$version
||
$v
<
$version
)
{
$version
=
$v
;
}
}
}
return
$version
;
}
}
Loading