Repository navigation
fix(bin): allow GitLab merges only when CI is confirmed unable to run at all - #18
Merged
Merged
Conversation
…nes in fm-pr-merge.sh A GitLab merge request with no head pipeline was always refused, whether the project genuinely cannot run CI or a pipeline simply has not run yet on this one request. fm-pr-merge.sh now reads the project's own jobs_enabled and builds_access_level, live, only when the head pipeline is absent, and relaxes the pipeline check only when those confirm CI can never run there. A pipeline that ran and failed, is still running, or ran at a stale commit is always refused regardless of that project setting. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018Muwy5vLvuiW4qDadEFUtA
… for CI-disabled exception
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.
Intent
Fix bin/fm-pr-merge.sh so it can distinguish "no automated checks exist at all" from "checks could run but didn't or failed" when merging a GitLab merge request.
Concrete failure: fm-pr-merge.sh refuses a GitLab merge unless head_pipeline.status == "success" at the exact current head. On a project where CI is switched off at the project level (e.g. jobs_enabled=false / builds_access_level=disabled), head_pipeline is always null, so status reads "none" and every merge is refused forever, with no way to proceed except bypassing the tool. This blocked captain-authorized merges on real GitLab projects (GOPlannerWeb has jobs_enabled=false and a .gitlab-ci.yml it can never run; the Android project has no pipeline configured either).
Requirements:
What Changed
bin/fm-pr-merge.sh: addedgitlab_ci_disabled_at_project_level(), which live-reads a GitLab project'sjobs_enabled/builds_access_levelviaglab api projects/<encoded>and returns success only when CI is structurally incapable of running there.notice:line naming the project and itsjobs_enabled/builds_access_levelvalues.docs/architecture.mdanddocs/gitlab-merge-watch.mdto describe the new exception and point to the script header as the source of truth for its exact conditions.tests/fm-pr-merge.test.shwith cases for: CI disabled at the project level (allowed), CI enabled but no pipeline on the MR (refused), a failed pipeline (refused), a pipeline succeeded at a stale commit (refused), and a pipeline succeeded at head (allowed, unchanged) — all exercised through the script's interface rather than by asserting source bytes.No caller-facing opt-in flag was added: the relaxation is gated purely on a fresh, per-call live read of the project's own forge-reported capability, which cannot go stale the way a passed-in or remembered flag could, so there's no separate flag to keep in sync with reality. The GitHub merge path is unchanged.
Risk Assessment
✅ Low: The change is narrowly scoped to the GitLab pipeline-refusal path, correctly reads live project capability (jobs_enabled/builds_access_level) only when no head pipeline exists, never relaxes a failed/stale/running pipeline, preserves all other pre-merge conditions and multi-condition refusal reporting, leaves GitHub untouched, is covered by thorough behavior-driven tests for every required scenario in the intent, and passes fm-lint.sh.
Testing
Ran the colocated fm-pr-merge.test.sh suite (30 cases including 6 new ones added by this change) and all pass, verified the new tests are non-vacuous by confirming they fail against the pre-fix script, and confirmed fm-lint.sh reports no ShellCheck issues; no UI surface exists for this CLI script change so the test transcript is the product-level evidence.
Evidence: fm-pr-merge.test.sh full run (target commit) — 6 new GitLab CI-capability tests all pass
Evidence: Regression check: same test against base commit (55db226) bin/fm-pr-merge.sh fails as expected
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-pr-merge.sh:172- gitlab_ci_disabled_at_project_level() prints its 'merging with no pipeline check' notice as soon as project settings confirm CI is disabled, before the other pre-merge conditions (state, mergeable, conflicts, discussions) are evaluated. If one of those unrelated conditions also fails, stderr will show both the 'merging because none can ever run' notice and a subsequent 'error: refusing to merge' block for a different reason, which reads as contradictory even though the final refusal is correct. Purely a message-ordering nit; no functional impact since the merge is still correctly refused.✅ **Test** - passed
✅ No issues found.
bash tests/fm-pr-merge.test.sh (full targeted suite for this script, 30/30 passing on target commit)Reverted bin/fm-pr-merge.sh to base commit 55db226 content and reran tests/fm-pr-merge.test.sh to confirm the new 'gitlab-ci-disabled-jobs' case fails (exit 1 vs expected 0), proving it's a real regression test, then restored the target commit's file via git checkoutbash bin/fm-lint.sh bin/fm-pr-merge.sh (ShellCheck 0.11.0, clean, exit 0)git status --short (confirmed no leftover artifacts in the worktree after testing)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.