Epic: Refactor Commits API to use standard keyset pagination patterns
## Summary Refactor the Commits API keyset pagination implementation to align with GitLab's established patterns for git object pagination. This replaces the approach in !229705 with a cleaner, more maintainable architecture. ## Background MR !229705 adds cursor-based pagination to the Commits API to fix broken pagination when using `all=true` (issue #586997). During backend pairing, we decided to: 1. **Improve code quality** - Leverage existing patterns like `Gitlab::Pagination::Keyset::Pager` and create a `CommitsFinder` 2. **Break into smaller MRs** - Preparatory refactoring first, then final implementation 3. **Assign to Source Code Backend team** - This aligns with team ownership ## Problem Being Solved When calling `/api/v4/projects/:id/repository/commits?all=true&page=N`, pagination is broken - every page returns the same commits. This is because Git's `--reverse` flag reverses output *after* `--skip` and `--max-count` are applied. ## Proposed Solution Follow the established pattern used by `BranchesFinder`, `TagsFinder`, and `TreeFinder`: 1. Create `CommitsFinder` class with `execute(gitaly_pagination:)` method 2. Integrate with `GitalyKeysetPager` for header generation 3. Refactor API endpoint to use finder + pager (thin controller pattern) ## Benefits - **Consistency**: Aligns with existing git object pagination patterns - **Testability**: Unit tests on Finder, not just API integration tests - **Reusability**: GraphQL resolver could also use CommitsFinder ## Sub-Issues This epic tracks the following work items (in order): 1. [ ] Style: Apply rubocop auto-corrections to commits.rb (preparatory cleanup) 2. [ ] Create CommitsFinder class 3. [ ] Integrate CommitsFinder with GitalyKeysetPager 4. [ ] Refactor Commits API to use CommitsFinder + keyset pager 5. [ ] Update documentation for keyset pagination on Commits API ## References - Original MR: !229705 - Original issue: #586997 - Keyset pagination docs: https://docs.gitlab.com/api/rest/#keyset-based-pagination - Existing patterns: - `lib/gitlab/pagination/keyset/pager.rb` - `app/finders/branches_finder.rb` - `app/finders/tags_finder.rb`
issue