Fix reset_required_approvals to support V2 approval rules

Update the reset_required_approvals method in the MergeRequest model to correctly reset approval counts for both v1 and v2 approval rule systems.

Benefits:

  • Ensures approval counts are correctly reset when MR target branches change
  • Maintains backward compatibility with v1 approval rules
  • Prevents stale approval data when rules change due to branch updates
  • Supports the v2 approval rules architecture

Requirements (validate these during implementation and adjust as needed):

  • Update reset_required_approvals method in EE::MergeRequest model
  • Use approval_rules_for helper to get the appropriate rule set (v1 or v2)
  • Reset approvals_required to 0 for all rules when target branch changes
  • Handle both v1 and v2 approval rule models correctly
  • Add specs for v1 and v2 scenarios
  • Ensure method works when disable_overriding_approvers_per_merge_request is enabled

Reference: v2 Approval Rules POC - See ee/app/models/ee/merge_request.rb lines 903-905

Edited Feb 12, 2026 by 🤖 GitLab Bot 🤖
Assignee Loading
Time tracking Loading