Skip to content

fix: leave excluded labels out of dry-run deletions - #1105

Open
TovaBecker wants to merge 1 commit into
github-community-projects:main-enterprisefrom
TovaBecker:tova.becker/fix-excluded-label-deletions
Open

TovaBecker wants to merge 1 commit into
github-community-projects:main-enterprisefrom
TovaBecker:tova.becker/fix-excluded-label-deletions

Conversation

@TovaBecker

@TovaBecker TovaBecker commented Oct 13, 2026 •

Copy link
Copy Markdown

Fixes #764

Why

Labels matching labels.exclude are never deleted, but the dry-run PR comment still lists every one of them under deletions. With a broad pattern such as exclude: [{ name: '.*' }] (keep all existing labels, add a few managed ones), every existing label in every repo shows up as a deletion, including its id, node_id, and url.

In one organization with 51 repos, this filled the comment to the 55,536-character limit after 8 repos. About 93% of the comment was these phantom deletions, and the real changes for the remaining repos were cut off.

The cause: Labels.remove() skips excluded labels, but the summary is built by compareDeep in Diffable.sync(), which compares all existing labels with the config and doesn't know about exclude.

Approach

  • Filter excluded labels out of the existing labels in Labels.find(), so they never enter the comparison, the summary, or remove().
  • Keep excluded labels that the config manages (matched by name or oldname), so they can still be updated or renamed.
  • Apply mode is unchanged: excluded labels were already never deleted.

Validation

  • Full unit suite: 1006 passed, 12 skipped. Integration suite: 106 passed.
  • 2 new tests in test/unit/lib/plugins/labels.test.js: an excluded label doesn't appear in the dry-run results (fails without the fix), and excluded labels that the config manages are still updated, renamed, and created.
  • ESLint and standard report no new diagnostics on touched files.

@TovaBecker
TovaBecker marked this pull request as ready for review October 13, 2026 10:09
Copilot AI balanced review requested due to automatic review settings October 13, 2026 10:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused implementation matches the intended behavior and is adequately covered by tests.

0 open findings

What changed in this PR

Filters excluded labels from dry-run comparisons while retaining managed labels for updates and renames.

Changes:

  • Excludes unmanaged protected labels from comparison results.
  • Adds dry-run coverage for exclusion, update, rename, and creation behavior.
File Description
lib/​plugins/​labels.js Filters unmanaged excluded labels during discovery.
test/​unit/​lib/​plugins/​labels.test.js Verifies corrected dry-run behavior.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

This branch has not been deployed

No deployments
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.

Excluding labels will still show as deletion

2 participants