Support path parameter with keyset pagination in Commits API

Why

Developers need to fetch the full commit history of a specific file across all branches, which requires filtering by path and paginating correctly at the same time. Keyset pagination handles the all=true case correctly, but it rejected the path parameter with a 400 error. This change lets path work with keyset pagination so a single request can filter by file path and page through the results correctly.

What

Enables the path parameter to work with keyset pagination (pagination=keyset) in the Commits API (GET /projects/278964/repository/commits).

Part of epic &21573, closing #595513 (closed). Follows the finder/pager refactor merged in !240477 (merged) (#595508 (closed)).

Gitaly's ListCommits RPC already supports path filtering via its paths field. Originally we thought we might need some extra gitaly work which is why this wasn't included initially, but it turned out to already be supported.

Keyset mode remains gated behind the commits_keyset_pagination feature flag (default off); when off, behavior is unchanged.

How to set up and validate locally

  1. In rails console: Feature.enable(:commits_keyset_pagination), then gdk restart rails-web.
  2. Fetch a path-filtered keyset page:
    curl -s -D - --header "PRIVATE-TOKEN: $TOKEN" \
      "http://gdk.test:3000/api/v4/projects/$ID/repository/commits?pagination=keyset&path=<dir>&per_page=5"
    Expect 200, results limited to commits touching <dir>, and a Link: ...; rel="next" header. Walk the page_token and confirm subsequent pages return different, non-overlapping commits that still touch the path.
  3. Confirm the same path without pagination=keyset (offset mode) returns the same set of commits.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist.

Related to #595513 (closed)

Edited by Hunter Stewart

Merge request reports

Loading
Loading