Skip to content

fix(gitlab): discard label removal events on merge requests#2785

Open
zakisk wants to merge 1 commit into
tektoncd:mainfrom
zakisk:SRVKP-12428-discard-label-removal-events-gitlab
Open

fix(gitlab): discard label removal events on merge requests#2785
zakisk wants to merge 1 commit into
tektoncd:mainfrom
zakisk:SRVKP-12428-discard-label-removal-events-gitlab

Conversation

@zakisk

@zakisk zakisk commented Jun 16, 2026

Copy link
Copy Markdown
Member

📝 Description of the Change

Label removal events on GitLab merge requests were incorrectly triggering pipeline runs. The hasOnlyLabelsChanged check used an OR condition that matched both additions and removals. Changed to compare current vs previous label count so only label additions are processed.

🔗 Linked GitHub Issue

Fixes #

🧪 Testing Strategy

  • Unit tests
  • Integration tests
  • End-to-end tests
  • Manual testing
  • Not Applicable

🤖 AI Assistance

AI assistance can be used for various tasks, such as code generation,
documentation, or testing.

Please indicate whether you have used AI assistance
for this PR and provide details if applicable.

  • I have not used any AI assistance for this PR.
  • I have used AI assistance for this PR.

Important

Slop will be simply rejected, if you are using AI assistance you need to make sure you
understand the code generated and that it meets the project's standards. you
need at least know how to run the code and deploy it (if needed). See
startpaac to make it easy
to deploy and test your code changes.

If the majority of the code in this PR was generated by an AI, please add a Co-authored-by trailer to your commit message.
For example:

Co-authored-by: Claude noreply@anthropic.com

✅ Submitter Checklist

  • 📝 My commit messages are clear, informative, and follow the project's How to write a git commit message guide. The Gitlint linter ensures in CI it's properly validated
  • ✨ I have ensured my commit message prefix (e.g., fix:, feat:) matches the "Type of Change" I selected above.
  • ♽ I have run make test and make lint locally to check for and fix any
    issues. For an efficient workflow, I have considered installing
    pre-commit and running pre-commit install to
    automate these checks.
  • 📖 I have added or updated documentation for any user-facing changes.
  • 🧪 I have added sufficient unit tests for my code changes.
  • 🎁 I have added end-to-end tests where feasible. See README for more details.
  • 🔎 I have addressed any CI test flakiness or provided a clear reason to bypass it.
  • If adding a provider feature, I have filled in the following and updated the provider documentation:
    • GitHub App
    • GitHub Webhook
    • Gitea/Forgejo
    • GitLab
    • Bitbucket Cloud
    • Bitbucket Data Center

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request modifies the GitLab provider's event detection logic to determine if only labels have changed by comparing the length of current and previous labels. It also introduces a helper function and several test cases to verify different label change scenarios. The review feedback points out a critical bug in this implementation: comparing only the slice lengths fails to detect label changes when a label is added and another is removed simultaneously (as the total count remains unchanged). A code suggestion is provided to correctly identify when at least one new label has been added, along with a recommendation to add a corresponding test case for this scenario.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread pkg/provider/gitlab/detect.go Outdated
Comment thread pkg/provider/gitlab/detect_test.go
@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.20%. Comparing base (ffc5092) to head (9951a1d).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2785      +/-   ##
==========================================
+ Coverage   60.19%   60.20%   +0.01%     
==========================================
  Files         211      211              
  Lines       21274    21280       +6     
==========================================
+ Hits        12806    12812       +6     
  Misses       7671     7671              
  Partials      797      797              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@zakisk

zakisk commented Jun 16, 2026

Copy link
Copy Markdown
Member Author

why lint rules are forced in this PR 🤔
https://github.com/tektoncd/pipelines-as-code/pull/2785/checks?check_run_id=81605577700

@zakisk zakisk force-pushed the SRVKP-12428-discard-label-removal-events-gitlab branch from e0d0fff to 494b7fc Compare June 16, 2026 18:25
Comment thread pkg/provider/gitlab/detect.go Outdated
@zakisk zakisk force-pushed the SRVKP-12428-discard-label-removal-events-gitlab branch from 494b7fc to 2e6f8f9 Compare June 23, 2026 19:07
@zakisk

zakisk commented Jun 24, 2026

Copy link
Copy Markdown
Member Author

/retest

@zakisk zakisk requested a review from theakshaypant June 25, 2026 06:55
Comment thread pkg/provider/gitlab/detect.go Outdated

@chmouel chmouel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review: found 1 issue.

Comment thread pkg/provider/gitlab/detect.go
Comment thread pkg/provider/gitlab/detect.go Outdated
Label removal events on GitLab merge requests were incorrectly triggering
pipeline runs. The hasOnlyLabelsChanged check used an OR condition that
matched both additions and removals. Changed to compare current vs previous
label count so only label additions are processed.

Signed-off-by: Zaki Shaikh <zashaikh@redhat.com>

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@zakisk zakisk force-pushed the SRVKP-12428-discard-label-removal-events-gitlab branch from 2e6f8f9 to 9951a1d Compare June 30, 2026 11:32
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.

3 participants