Reputation: 135
I have a number of issues assigned to me to work on, and I've made merge requests to fix many of them. I am looking for a query that would let me filter out issues with a related merge request.
The GitLab instance I'm using is at v14.4.2.
I've looked in the docs for both basic search and advanced search, but can't figure out a good query for this.
The equivalent query in GitHub would be is:issue is:open assignee:legowerewolf -linked:pr
Upvotes: 2
Views: 1247
Reputation: 135
As per @Arty-chan above, there's no built-in way to do this. After futzing around in PowerShell and with the API for a bit, I came up with this:
$GitlabToken = '[your GitLab PAT with API read access]'
$APIRoot = 'https://[your GitLab server here]/api/v4'
$TokenHeader = @{
"PRIVATE-TOKEN" = $GitlabToken
}
$User = Invoke-RestMethod -Method Get -Uri "$APIRoot/user" -Headers $TokenHeader
$UserOpenIssues = Invoke-RestMethod -Method Get -Uri "$APIRoot/issues" -Headers $TokenHeader -Body @{
assignee_id = $User.id
state = "opened"
scope = "all"
}
foreach ($Issue in $UserOpenIssues) {
$Issue | Add-Member -MemberType NoteProperty -Name "related_merge_requests" -Value (
Invoke-RestMethod -Method Get -Uri "$APIRoot/projects/$($Issue.project_id)/issues/$($Issue.iid)/related_merge_requests" -Headers $TokenHeader | Where-Object { $_.state -eq "opened" }
)
}
$UserOpenIssues = $UserOpenIssues | Sort-Object -Property @{Expression = { $_.labels[0] } }
Write-Host "Open issues without a merge request assigned to $($User.name):"
$UserOpenIssues
| Where-Object { $_.related_merge_requests.Count -eq 0 }
| Format-Table -Property @(
@{name = "Reference"; expression = { $_.references.full } }
@{name = "Title"; expression = { $_.title } }
@{name = "Labels"; expression = { $_.labels } }
)
Upvotes: 0
Reputation: 2998
As of writing, that's not possible.
Generally, if a feature is not listed in the docs, then it hasn't been implemented. You can search for and existing feature request in the GitLab issue tracker (though I didn't find one) or file a feature request.
Upvotes: 2