Update canonical_sha_intersection to accept commit_count parameter

What does this MR do and why?

Updates the canonical_sha_intersection method to accept a commit_count parameter, enabling this is part of the rollback safety enhancement implementation.

Content

Background Context

While working on the MergeRequestsProcessor module for detecting security fixes and incident resolutions in rollbacks, we encountered this error:

Failed to find auto-deploy intersection -- {project: "gitlab-org/gitlab", sha: "fa4bf4af667f87296fb82892e0774ca51d3f4309"}

Whenever the commits were more than 300.

This led to MR !4319 which made the deployment util pagination limit configurable. Now that !4319 (merged) is merged, we need to update the DeploymentsInformation class to utilize the new configurable limit functionality.

What This MR Changes

Core Method Updates:

  • Add commit_count parameter to canonical_sha_intersection method signature
  • Update canonical_deployments method to accept and pass the commit_count parameter
  • Pass limit: commit_count to auto_deploy_intersection calls for dynamic pagination

Deployment Pagination Improvements:

  • Add per_page: 30 parameter to deployments method (increased from default 20)
  • Pass per_page through opts parameter to GitlabClient.deployments
  • Resolve pagination issues where deployments beyond the first 20 records were missed

Test Updates:

  • Update unit tests to match new method signatures
  • Add commit_count parameter to test method calls

Why This Change is Needed

The canonical_sha_intersection method calls auto_deploy_intersection which now accepts a configurable limit parameter. By passing the actual commit count between deployment SHAs, we can:

  1. Prevent intersection failures for large repositories like gitlab-org/gitlab
  2. Enable accurate rollback analysis by ensuring we search through enough commits
  3. Resolve deployment lookup failures by searching beyond the default 20 deployment records
  4. Continue development of the MergeRequestsProcessor module for security/incident detection

Related Issue gitlab-com/gl-infra/delivery#20923 (closed)

Author Check-list

  • Has documentation been updated?
Edited by Maina Ng'ang'a

Merge request reports

Loading