feat(mr): add --skip-ci to mr merge

Description

Adds --skip-ci to glab mr merge. It works like the ci.skip push option: it adds [ci skip] to the commit that lands on the target branch, so that commit does not start a pipeline. It does not merge immediately, change auto-merge, skip the merge request's own pipelines, or bypass pipelines the project requires, following @phikai's comment on the issue.

  • Adds [ci skip] to the merge commit message, and also to the squash commit message with --squash.
  • When no --message is given, the MR title is used as the message, because an empty message lets GitLab write its own and the marker would be lost. This replaces the project's merge commit template, which the help text documents.
  • A message that already has a marker GitLab recognizes (the same case-insensitive pattern GitLab uses, for example [skip ci] or [CI-Skip]) is left unchanged.
  • With --rebase, the rebase request is sent without skip_ci, so the merge request pipeline still runs on the rebased code.
  • In a project that uses fast-forward merges, no merge commit is created, so --skip-ci returns an error unless --squash is used. It also returns an error with --rebase, and when the project does not allow squashing.
  • The help text notes that the marker stays on the commit, so a tag pushed on it later also skips its pipeline.

Resolves #7926 (closed)

How has this been tested?

  • Added cases to TestMrMerge in internal/commands/mr/merge/mr_merge_test.go:
    • --skip-ci adds the marker to the merge commit message and keeps auto-merge
    • without --skip-ci, no commit message is sent
    • --skip-ci --squash adds the marker to both commit messages
    • a message that already has the marker ([skip ci], [CI-Skip]) is unchanged
    • --skip-ci --rebase does not send SkipCI on the rebase request, and adds the marker to the merge commit message
    • in a fast-forward project, --skip-ci --squash adds the marker to the squash commit message
    • in a fast-forward project, --skip-ci without --squash, --skip-ci --rebase, and a project that does not allow squashing each return an error
    • an error fetching the project is returned
Edited by Jay McCure

Merge request reports

Loading
Loading