Integrate Gitaly CountCommits revisions parameter support

Summary

This MR integrates support for the new revisions parameter in Gitaly's CountCommits RPC, which was introduced in gitaly!8349 (merged).

Related to #586893 (closed)

Changes

Updated commit_count Method

The commit_count method in Gitlab::GitalyClient::CommitService now supports:

  • New revisions parameter: Accepts an array of revisions and pseudo-revisions
  • Pseudo-revision support: --all, --branches, --tags, --not, --glob
  • Proper precedence: revisions > all > revision
  • Backward compatibility: Existing revision and all parameters continue to work

Implementation Details

# Legacy usage (still supported)
commit_count('master')
commit_count('master', all: true)

# New usage with revisions
commit_count(nil, revisions: ['master'])
commit_count(nil, revisions: ['--all'])
commit_count(nil, revisions: ['branch-2', '--not', 'branch-1'])
commit_count(nil, revisions: ['feature-a', 'feature-b'])

Test Coverage

Added comprehensive test coverage for:

  • Single revision via revisions parameter
  • Multiple revisions
  • Pseudo-revisions (--all, --branches, --not)
  • Precedence rules (revisions takes priority over all/revision)
  • Combination with filters (before, after, path, max_count, first_parent)
  • UTF-8 encoding handling

Benefits

  • More efficient: Count commits across multiple refs in a single RPC call
  • More flexible: Support for complex revision queries using pseudo-revisions
  • Consistent API: Aligns with ListCommits functionality
  • Better performance: Reduces multiple RPC calls for multi-reference operations

Migration Path

The revision and all parameters are soft deprecated but will remain functional. Future code should use the revisions parameter for new implementations.

Next Steps

After this MR:

  1. Update Gitlab::Git::Repository to expose the new parameter
  2. Identify and update callers that would benefit from the new functionality
  3. Update GraphQL/REST API endpoints as needed

Merge request reports

Loading