Migrate commit_count to always use revisions parameter internally
Summary
This MR implements the plan outlined in #587518 (closed) to migrate the commit_count method to internally convert legacy revision and all parameters to the new unified revisions parameter when calling Gitaly.
Changes
Feature Flag
Added count_commits_use_revisions_only feature flag (disabled by default) to control the rollout.
Updated commit_count Method
When the feature flag is enabled, the method now:
- Converts
refparameter →revisions: [ref] - Converts
all: true→revisions: ['--all'] - Passes
revisionsparameter through unchanged
Backward Compatibility
- External API remains unchanged - all existing calls continue to work
- When flag is disabled, uses the existing behavior
- When flag is enabled, converts parameters internally before calling Gitaly
Test Coverage
Added comprehensive tests for the new conversion logic:
- Single revision conversion
-
all: trueconversion to--all -
revisionsparameter passthrough - Error handling for missing revisions
- Compatibility with filters (before, after, path, max_count, first_parent)
- UTF-8 encoding preservation
Migration Examples
External API stays the same:
# These all continue to work exactly as before
commit_count('master') # Internally: revisions: ['master']
commit_count(nil, all: true) # Internally: revisions: ['--all']
commit_count(nil, revisions: ['feature-a', 'feature-b']) # Internally: revisions: ['feature-a', 'feature-b']
Benefits
- Simplified Gitaly code: Single code path in Gitaly for handling revisions
- Better maintainability: One way to handle all revision inputs
- Backward compatible: No changes to external API
- Future-proof: All code already using the modern parameter internally
Related
- Issue: #587518 (closed)
- Parent issue: #586893 (closed)
- Original MR: !219416 (merged)
Edited by Vasilii Iakliushin