Skip to content

Add diff count to CommitStats RPC

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Background

For commit rapid diffs we need to get a count of all the diff files to populate this badge on the commit page:

Screenshot_2024-10-25_at_12.29.46

Currently to get the count we are querying Gitaly for all diffs. Separately for rapid diffs we are querying for the first 5 diffs. As per @patrickbajao's comment we could try to use git diff --numstat to return the number of changed files and add this to the CommitStats RPC.

$ git diff --numstat
5       1       app/services/ci/job_artifacts/create_service.rb
22      0       spec/services/ci/job_artifacts/create_service_spec.rb

Proposed solution

A new files property is being added to CommitStats RPC in gitaly!7393 (merged).

From gitlab-rails perspective, we need to:

  1. Consume the new files property from RPC response
  2. Use the Gitlab::Git::Commit#stats in commit page for rapid diffs.
Edited by 🤖 GitLab Bot 🤖