Cover fast-forward merge when the target tip is unresolved

What does this MR do and why?

Adds a spec for fast_forward! when the target branch tip can't be resolved. rspec:undercoverage flagged the nil branch of &.sha on the prior target sha lookup on !260375 (merged). The gap predates that MR. Spec only.

Detailed context for AI agents
  • Uncovered line: app/services/merge_requests/merge_strategies/from_source_branch.rb:130, prior_target_sha = repository.commit(merge_request.target_branch_ref)&.sha. Undercover reported branches: 1/2 (80% method coverage). The nil branch was never exercised.
  • Pre-existing: master has the same &.sha on the bare target_branch read since 13d415ea (removal of verify_ff_merge_advancement). !260375 (merged) only changed the argument to target_branch_ref, which put the method in the undercoverage diff. That MR carries pipeline:skip-undercoverage.
  • New example: stubs repository.commit(target_branch_ref) to return nil and calls through for every other commit call. It asserts that ff_merge gets target_sha: nil and that the result is recorded.
  • Verification: the new example passes. With &. replaced by ., it fails with NoMethodError, so it covers the nil branch. The full from_source_branch_spec.rb passes (29 examples), and rubocop is clean.
  • No production code change, no changelog entry.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Merge request reports

Loading
Loading