Add diverging commits endpoint
Summary
Add GET /projects/:id/repository/diverging_commits, a REST endpoint that returns how many commits two refs have diverged by (behind/ahead). It also generalizes DivergingCommitCountsService so the endpoint can compute counts for arbitrary refs while the internal branches UI controller keeps its cached, branch-name-scoped path.
Closes #599031 (closed)
What does this MR do?
- Adds a public
diverging_counts(from, to, max_count:)method onDivergingCommitCountsServicethat computes counts directly (no caching), so arbitrary caller-supplied refs are never written to the shareddiverging_commit_counts_*cache namespace. The existingcall(branch)path keeps its Redis caching, keyed by branch name. - Adds the API endpoint implementation, presenting through
Entities::DivergingCommitCount. - Gates it behind the
repository_diverging_commits_apifeature flag (beta, disabled by default; 404 when off) and marks itroute_setting :lifecycle, :experiment. Available on all tiers — not license-gated. - Requires the
read_commitpermission, constrainsfrom/tolength, validatesmax_countas non-negative, and rate limits viaproject_repositories_diverging_commits. - Includes request and service specs.
- Includes OpenAPI documentation (v2 and v3).
Edited by John Cai