[go: up one dir, main page]

Skip to content

Rebase and merge with one click

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Problem

When using merge commit with semi-linear history and fast-forward merge methods, if the target branch has changed since the source branch was created or last rebased, the source branch will need to be rebased before merging in order to merge according to the selected merge method.

Currently, if GitLab detects a rebase is required, the users can click the Rebase button. Once the rebase is completed the Merge button will become available. This require more time as I have to return to MR to check when rebase is done and then merge.

Proposal

Now that FF-merge trains exists I think much of the implementation could also be re-used as follows (no Gitaly changes required):

  1. Use MergeRequests::CreateRefService to create a merge candidate ref, for example refs/merge-requests/:iid/rebase-merge
  2. Perform a fast-forward merge from refs/merge-requests/:iid/rebase-merge into the target branch. If the target branch has been updated in the meantime, this would gracefully fail (in which case we could retry or display an error to the user).

Further details

  • The importance of this feature is magnified by both the requirement for CI pipelines to pass before merging.
  • There is appetite to merge immediately after the rebase is successful without running CI. While some feel this should not be the default, those folks would like to have the option to make that desicion.
  • This will not solve contention between many merge requests with slow pipelines. See &4911 (closed) for Merge Trains with Fast Forward Merge support

Old proposal
  • For the two merge request methods (merge commit with semi-linear history and fast-forward merge), offer the ability to rebase and merge in a single action.
  • Note: For below, strikethrough indicates existing functionality that will be removed and bold indicates new functionality.
  1. No pipeline exists (No GitLab CI set up)
  • MR needs a rebase
    • MR is non-rebaseable
      • Merge button, and an error after clicking the button
      • Access to source branch: Rebase locally button that shows instructions (button; instructions modal) If rebase succeeds, show message “Ready to be merged automatically. Ask someone with write access to this repository to merge this request.”
      • No access to source branch: No buttons, only message to ask MR author to rebase locally (message)
    • MR is rebaseable
      • Access to only source branch: Rebase button (rebase) If rebase succeeds, show message “Ready to be merged automatically. Ask someone with write access to this repository to merge this request.”
      • Access to source AND target branch: Merge and Rebase only buttons. Merge will auto-rebase+merge immediately. (merge or rebase only) If Rebase only, after it succeeds, show Merge button.
      • No access to source branch: No buttons, only message to ask MR author to rebase (message)
  • MR does not need a rebase
    • Merge button
  1. Pipeline running
  • MR needs a rebase
    • MR is non-rebaseable
      • Merge button, and an error after clicking the button
      • Access to source branch: Rebase locally button that shows instructions (button; instructions modal) If rebase succeeds, show message “Ready to be merged automatically. Ask someone with write access to this repository to merge this request.”
      • No access to source branch: No buttons, only message to ask MR author to rebase locally (message)
    • MR is rebaseable
      • Access to only source branch: Rebase button (rebase) If rebase succeeds, show message “Ready to be merged automatically. Ask someone with write access to this repository to merge this request.”
      • Access to source AND target branch: Merge (blue button) and Rebase only buttons. Merge will auto-rebase+merge immediately. (merge or rebase only) If Rebase only, after it succeeds, show Merge (blue) and Merge when pipeline succeeds (orange) buttons.
      • No access to source branch: No buttons, only message to ask MR author to rebase (message)
      • Not in scope: Merge when pipeline succeeds button (blue) that will auto-rebase+merge when pipeline succeeds
  • MR does not need a rebase
    • Merge when pipeline succeeds button (blue)
    • Merge button (orange) to merge immediately
  1. Pipeline passed
  • Same as 1. No pipeline exists, above
  1. Pipeline failed
  • Pending discussion

Customers

Links / references

This page may contain information related to upcoming products, features and functionality. It is important to note that the information presented is for informational purposes only, so please do not rely on the information for purchasing or planning purposes. Just like with all projects, the items mentioned on the page are subject to change or delay, and the development, release, and timing of any products, features, or functionality remain at the sole discretion of GitLab Inc.

This page may contain information related to upcoming products, features and functionality. It is important to note that the information presented is for informational purposes only, so please do not rely on the information for purchasing or planning purposes. Just like with all projects, the items mentioned on the page are subject to change or delay, and the development, release, and timing of any products, features, or functionality remain at the sole discretion of GitLab Inc.

Edited by 🤖 GitLab Bot 🤖