Fix wrong commit count in push event payload
This fixes a regression in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/20916. We now only use the full commit count for the initial push to the default branch. Otherwise, we rely on the number of commits that we calculated occurred in the push.
The original behavior in 11.1.4:
- When a new branch is pushed,
@push_commits_count
was set to the total number of refs available for the branch. - For other branches,
@push_commits_count
would remainnil
. -
GitPushService#build_push_data
would build the push data with@push_commits_count
. - If this were
nil
, it would be set to the right value here: https://gitlab.com/gitlab-org/gitlab-ce/blob/v11.1.4/lib/gitlab/data_builder/push.rb#L60
Broken behavior:
-
GitPushService#push_commits_count
is always called. - The total number of commits is therefore always equal to the total number of refs available.