Unify diverging commit cache for MRs and Branches

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

  • Close this issue

To the best of my knowledge we're calculating diverging commits in both the merge requests (requested by API or WebUI), and the branches view. Both will calculate the diverging commit counts between two hashes. Which might, and probably will, overlap for many cases.

They do not share a cache however, decreasing the hit rate for both. Unifying them under a cache key based on the from and to SHA would allow them both to hit the same cache and maybe further DRY our codebase.

  • The MR numbers are calculated & cached in MergeRequest#diverged_commits_count
  • The branch vs HEAD numbers are calculated & cached in Repository#diverging_commits_count

/cc @godfat @reprazent

Edited Sep 26, 2025 by 🤖 GitLab Bot 🤖
Assignee Loading
Time tracking Loading