fix(gitlab): use diff_stats instead of changes_count for correct MR s…#8928
Open
bujjibabukatta wants to merge 1 commit into
Open
fix(gitlab): use diff_stats instead of changes_count for correct MR s…#8928bujjibabukatta wants to merge 1 commit into
bujjibabukatta wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
GitLab MR size is incorrectly inflated when a branch has multiple
sequential PRs. The
changes_countfield from GitLab's API returnscumulative line changes across all commits on the branch including
previous PRs, not just the current MR's diff.
Root Cause
GitLab's
changes_countsums all commits on the source branch.For multi-part PRs this means PR #3 shows 9292 lines changed
instead of the actual 6523 lines in that PR alone.
Fix
Use GitLab's
diff_statsfield (viainclude_diff_stats=truequery param) which returns additions/deletions relative to the
merge base — only what this PR itself introduces.
Changes
backend/plugins/gitlab/tasks/mr_extractor.go— addedDiffStatsstruct to
MergeRequestResand mappedAdditions/Deletionsin
convertMergeRequestbackend/plugins/gitlab/models/mr.go— addedAdditionsandDeletionsfields toGitlabMergeRequestbackend/plugins/gitlab/tasks/shared.go— addedinclude_diff_stats=truequery param toGetQuerybackend/plugins/gitlab/models/migrationscripts/— added migrationscript and registered it
Fixes #8888