Repository navigation
GitLab merge requests behind the forge descriptor (forge: "gitlab" config) - #1
Merged
Merged
Conversation
added 2 commits
October 30, 2026 16:39
A gitlabSource over GitLab's REST API (v4) maps merge requests onto the plugin's pull requests, and gitlabForge spells GitLab's URLs, fork refs, merge methods and sign-in. "forge": "gitlab" in config.json switches the plugin to it; GitHub stays the default, and the demo stays on GitHub. The descriptor now also builds the picker's source and answers the label hooks and status (newSource, api), so no call site names GitHub's client. The multi-host cursor and repo paging are shared (fanOut, pageHosts), and repo paths may nest (group/sub/project) when the forge says so.
The forge's comments still spoke of GitLab as a forge to come, and the list-cap notice was built at start-up, before the config chose the forge, so it said GitHub on GitLab.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Builds on mrolafsson#5 (stacked — base is
forge-agnostic, retarget tomainonce mrolafsson#5 lands). Implements mrolafsson#6.Summary
A GitLab mode behind the seams mrolafsson#5 created: a
gitlabForgedescriptor and agitlabSourceimplementingsourceover GitLab REST v4, stdlib only. GitHub stays the default and its behavior is unchanged. 179/179 tests pass (165 baseline + 14 new against a fake GitLab server).Switch
Runtime, from config:
"forge": "gitlab"in config.json (defaultgithub; unknown value = config error). The descriptor gains what the TUI and label hooks need per forge:newSource,prsForBranches,prsByNumber,viewer,startPrompt,nestedPaths(GitLab namespaces nest:group/sub/project). Call sites that hard-coded GitHub (tui.go, repopicker.go, labels.go, agents.go, status) now go through the descriptor — same text when GitHub is active. The demo stays on the GitHub forge.GitLab client (
gitlab.go, new)glab auth tokendoes not exist (gitlab-org/cli#8231, declined), so:GITLAB_TOKEN/GITLAB_ACCESS_TOKEN/OAUTH_TOKENenv, elseglab config get token --host <host>. HeaderAuthorization: Bearer <token>(accepted for PATs and OAuth tokens alike).GET /merge_requests?scope=created_by_me&state=opened; repo =GET /projects/:id/merge_requests. Paginationpage/per_pageviaX-Next-Page. No review-requested tab —caps.reviewRequested=false, the TUI hides it (and a remembered last-tab falls back to the first tab).Draft:/WIP:/[Draft]title prefixes, rewritten viaPUTon the MR title.PUT …/mergewithsha(pinned head — same "changed since load" protection as GitHub),squashper the project'ssquash_option; auto-merge sendsauto_merge+merge_when_pipeline_succeeds(covers older GitLab), off viacancel_auto_mergewith fallback to the pre-19.5 endpoint.head_pipelinejobs;allow_failurejobs are not required checks. Review decisions from approvals +/reviewers.Also in the diff
fanOut/pageHosts: the multi-host paging pulled out ofgithubSourceunchanged so both forges share it.pr.repo()cuts at the last/(identical forowner/name); remote/repo-key parsing accepts nested owners when the forge allows it.Tests
14 new tests in
gitlab_test.goagainst a fake GitLab server (in the style of the fake GitHub): list paging, MR→shared-struct mapping (incl.lockedstate, nested groups), merge pinning + 409, draft prefix handling, auto-merge on/off fallbacks, URL parsing (/-/merge_requests/N), fork refs, capability gating, repos picker, signed-out handling. Full suite 179/179; gofmt/vet clean.The commits:
0aa1273the feature,f17501ccomments/wording.Known limitations (documented on purpose, follow-up candidates)
difffield has no---/+++headers, so the current skip drops a real deleted-- comment/ added++xline; only@@needs skipping.https://host/gitlab/...): the project path is derived fromweb_url, so it comes out wrong and per-MR calls 404. Plain self-managed instances at the host root work.None of these regress anything — GitHub is untouched, and the GitHub-only paths are unchanged.