fix(mr): allow boolean flags to explicitly override project defaults

Summary

Fixes three boolean flags (--squash-before-merge, --remove-source-branch, --allow-collaboration) to allow users to explicitly override project defaults by setting them to false.

What was broken

Previously, these flags used plain bool types which couldn't distinguish between:

  • User didn't set the flag (should use project default)
  • User explicitly set --flag=false (should override project default)

Both cases resulted in the same behavior: the API field was not set, so GitLab used project defaults.

What changed

  • Changed three fields from bool to *bool:
    • SquashBeforeMerge
    • RemoveSourceBranch
    • AllowCollaboration
  • Updated flag handling in complete() to only set the pointer when the flag is explicitly provided
  • Updated run() to check for nil instead of a separate tracking field
  • Enhanced flag descriptions to clarify override behavior
  • Follows the established pattern from the project update command

Behavior now

For all three flags:

  • Flag omitted: API field is nil → GitLab uses project default
  • --flag or --flag=true: API field is true → Enable the setting
  • --flag=false: API field is falseDisable the setting (overrides project default)

Resolves: #8144 (closed)

Test plan

  • Added unit tests covering all three states for all affected flags
  • All existing tests pass
  • Documentation regenerated
Edited by Kai Armstrong

Merge request reports

Loading