Add file path filtering to commit list GraphQL endpoint

What does this MR do and why?

Adds a path argument to the Repository.commits GraphQL connection so commits can be filtered by file path. This is the backend half needed for file history views in the refactored Vue commit list (e.g. /<project>/-/commits/<ref>/<file-path>).

Changes

  • CommitsResolver — Add optional path argument (String). Normalize empty strings to nil via .presence in list_commits_arguments so they don't leak through as unfiltered-but-different queries.
  • Repository#list_commits — Accept and forward the path keyword argument.
  • Gitlab::Git::Repository#list_commits — Pass path through to the Gitaly client.
  • GitalyClient::CommitService#list_commits — Push the path onto request.paths (the Gitaly ListCommitsRequest repeated bytes field). Guarded with .present? as a defensive check.

Tests added

  • commits_resolver_spec — Verifies path filtering returns only commits touching the given file, returns fewer results than unfiltered, and normalizes empty string path to nil.
  • repository_spec — Verifies the path parameter is passed through to the raw repository.
  • commit_service_spec — Verifies the path is included in the Gitaly request and that empty string paths result in an empty paths field.

The frontend changes are in !233685

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #598435

Edited by Chaoyue Zhao

Merge request reports

Loading