GitLab adapter: Repo box readers and update branch #140
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
On GitLab the Repo box (README, Branches, Files tabs) is empty and
uis unavailable until the adapter implements the readers andBranchUpdater. Parent: #137. Depends on #138; pick this up after #138 merges.Acceptance criteria
forge.ReadmeReader,forge.BranchReader,forge.TreeReaderandforge.BranchUpdater, so the Repo box's README, Branches and Files tabs anduwork as on Forgejo (design.md → Repo box; Keymapu).uon GitLab offers rebase only, because GitLab's API can rebase an MR but cannot merge the target branch into it (design.md → Keymapualready says "GitHub offers merge only"; GitLab is the mirror case, forced by the API). design.md's twousentences are updated to say so.Plan
In
internal/forge/gitlab:GetReadme:GET /projects/:id/repository/tree?ref=<default>(root, paginated), pick the name with the same ranking asinternal/forge/gitea/readme.go(README.md,README.markdown,README, otherREADME.*), thenGET …/repository/files/:path?ref=<default>(base64).refis required on GitLab, so use the project'sdefault_branch. None found →ErrNotFound.ListBranches:GET …/repository/branches(paginated). Tip commit is inline (commit.id, title, author_name, committed_date);Default←default. No extra calls.ListCommits:GET …/repository/commits?ref_name=<branch>&per_page=30(first page only). Unknown branch →ErrNotFound.ListTree:GET …/repository/tree?path=<dir>&ref=<ref>&per_page=100, paginated.typetree→ dir,blob→ file,commitor mode160000→ submodule. A 404 (missing path since GitLab 17.7, or an empty repo) →ErrNotFound; an older server's 200[]for a missing path stays an empty listing. Sizes aren't in the tree listing; leaveSizezero and letReadFileenforce the cap.ReadFile:HEAD …/repository/files/:path?ref=first and refuse whenX-Gitlab-Sizeexceedscore.MaxPreviewSize(match how core treats an oversized file), elseGET …/repository/files/:path/raw?ref=for exact bytes (the JSON form transcodes non-UTF-8 text, which would hide binaries). The whole path is URL-encoded,/included, per #138's addressing. Check howcore.MaxPreviewSizeis applied today before choosing where the check lives.UpdateStyles:[UpdateRebase].UpdateBranch:PUT …/merge_requests/:iid/rebase; 202 is success (the rebase finishes asynchronously; the existing refresh afterupicks up the new head). 403 and 409 →ErrRefusedwith GitLab'smessage.UpdateMerge→ErrUnsupported.Context
internal/forge/github/{readme,branches,files,update}.goand their tests. Interfaces:internal/forge/forge.go(ReadmeReader,BranchReader,TreeReader,BranchUpdater).refand a fully encoded path;HEADon the files endpoint returnsX-Gitlab-Size;/rawreturns exact bytes; blobs over 10 MB are limited to 5 requests a minute. Rebase returns 202{"rebase_in_progress":true}; 403Cannot push to source branch/Source branch is protected from force push; 409Failed to enqueue the rebase operation. No API merges the target into an MR.Out of scope
Diffs. Polling the async rebase to completion.
🤖 Picked up through composer-lite on branch
feature/140-gitlab-repo; the plan is this ticket body.🤖 MR open: #147
🤖 merged: #147