Skip to content

fix(gitlab): use diff_stats instead of changes_count for correct MR s…#8928

Open
bujjibabukatta wants to merge 1 commit into
apache:mainfrom
bujjibabukatta:fix/#8888
Open

fix(gitlab): use diff_stats instead of changes_count for correct MR s…#8928
bujjibabukatta wants to merge 1 commit into
apache:mainfrom
bujjibabukatta:fix/#8888

Conversation

@bujjibabukatta

Copy link
Copy Markdown
Contributor

Problem

GitLab MR size is incorrectly inflated when a branch has multiple
sequential PRs. The changes_count field from GitLab's API returns
cumulative line changes across all commits on the branch including
previous PRs, not just the current MR's diff.

Root Cause

GitLab's changes_count sums 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_stats field (via include_diff_stats=true
query param) which returns additions/deletions relative to the
merge base — only what this PR itself introduces.

Changes

  • backend/plugins/gitlab/tasks/mr_extractor.go — added DiffStats
    struct to MergeRequestRes and mapped Additions/Deletions
    in convertMergeRequest
  • backend/plugins/gitlab/models/mr.go — added Additions and
    Deletions fields to GitlabMergeRequest
  • backend/plugins/gitlab/tasks/shared.go — added
    include_diff_stats=true query param to GetQuery
  • backend/plugins/gitlab/models/migrationscripts/ — added migration
    script and registered it

Fixes #8888

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug][Gitlab] PR Size Incorrectly include previous PR

1 participant