GitLab auto-merge fails: glab mr merge uses nonexistent --should-remove-source-branch flag #284
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?
Root Cause
src/mr/services/gitlabMergePoller.ts→GitLabMergePoller.merge()hardcodes:--should-remove-source-branchis not a real glab flag. Confirmed via:glab help mr merge(v1.110.0)glab mr merge --helpdocsThe correct flag is
-d, --remove-source-branch.glab's cobra parser rejects the unknown flag before merging, dumping a usage/help block to stderr. This causes 100% of GitLab auto-merge attempts to fail — not transient/version-drift, present since inception (likely confusing GitLab REST's
should_remove_source_branchJSON field with glab's actual CLI flag name).Observed Failure
(Full glab usage dump is truncated/mangled by
makeCliRunner's error wrapping — see fix item 3 below.)Blast Radius
GitLab-only.
githubMergePoller.ts(gh pr merge --merge --auto) — valid flags, unaffected.forgejoMergePoller.ts— pure REST call, no CLI flags, unaffected.Fix Scope (full hardening)
--should-remove-source-branch→--remove-source-branchingitlabMergePoller.ts.gitlabMergePoller.test.ts's test that currently asserts the buggy flag string ('glab:mr merge 42 --should-remove-source-branch'and itstoHaveBeenCalledWithassertion) — otherwise the regression test keeps the bug locked in.makeCliRunner(cliMergePollerBase.ts) to append captured stderr to theMrClientErrormessage when present, e.g.`${command} command failed: ${message}\nstderr: ${stderr}`— no new fields added, fully backward compatible with existing consumers/tests.gitlabMergePoller.tsdocumenting the correct flag name and linking to https://docs.gitlab.com/cli/mr/merge/, warning future editors to verify againstglab help mr mergebefore changing it.Verification
Unit tests only:
gitlabMergePoller.test.ts) and the stderr-appended error message (cliMergePollerBase.test.ts).npm testandnpm run lintto confirm green.pi-loop opened and merged a pull request for this issue: #285