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 optionalpathargument (String). Normalize empty strings tonilvia.presenceinlist_commits_argumentsso they don't leak through as unfiltered-but-different queries.Repository#list_commits— Accept and forward thepathkeyword argument.Gitlab::Git::Repository#list_commits— Passpaththrough to the Gitaly client.GitalyClient::CommitService#list_commits— Push the path ontorequest.paths(the GitalyListCommitsRequestrepeated 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 tonil.repository_spec— Verifies thepathparameter 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 emptypathsfield.
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