Create a diff statistics endpoint
As mentioned on https://gitlab.com/gitlab-org/gitlab-ce/issues/44806, currently we calculate diff file additions / deletions of each file through parsing of each diff, which seems inefficient. We could be using git diff --numstat
:
Example:
git diff --numstat rev1..rev2 <file> # file being optional
Would return (additions, deletions of each file respectively):
5 0 changelogs/unreleased/44184-issues_ical_feed.yml
1 0 config/routes/profile.rb
19 0 db/migrate/20180315141051_add_calendar_token_to_users.rb
3 1 db/schema.rb
4 0 doc/user/project/issues/due_dates.md
1 1 lib/gitlab/auth/request_authenticator.rb
12 4 lib/gitlab/auth/user_auth_finders.rb
4 0 spec/factories/users.rb
1 1 spec/features/dashboard/issues_filter_spec.rb
48 0 spec/features/ics/dashboard_issues_spec.rb
14 0 spec/features/issues_spec.rb
18 0 spec/features/profile_spec.rb
40 0 spec/helpers/calendar_helper_spec.rb
5 5 spec/lib/gitlab/auth/request_authenticator_spec.rb
19 7 spec/lib/gitlab/auth/user_auth_finders_spec.rb
10 0 spec/models/user_spec.rb
4 0 spec/routing/routing_spec.rb
We could wrap it in a endpoint and return:
[
{
"filename": ".gitattributes",
"additions": 1,
"deletions": 0
},
...
]
This would help solving https://gitlab.com/gitlab-org/gitlab-ce/issues/44806 and https://gitlab.com/gitlab-org/gitlab-ce/issues/20282.