Skip to content

Deduplicate Rust guard case-insensitive parsing - #16081

Merged
lpcox merged 2 commits into
mainfrom
copilot/rust-guard-reuse-matches-any-ci
Nov 6, 2026
Merged

lpcox merged 2 commits into
mainfrom
copilot/rust-guard-reuse-matches-any-ci

Conversation

Copilot AI commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Author-association parsing duplicated the permission parser’s trimmed, case-insensitive matching. Integrity-level parsing maintained the same string-to-variant mapping through a branch chain.

  • Shared matching: Move matches_any_ci to constants.rs as pub(crate) and reuse it in both parsers.
  • Integrity mapping: Replace MinIntegrity::from_policy_str branches with a constant lookup table; retain whitespace trimming and unknown-value rejection.
  • Regression coverage: Preserve the existing helper test and extend coverage for empty inputs, internal whitespace, and normalized integrity round-trips.
if matches_any_ci(raw, &["OWNER", "MEMBER", "COLLABORATOR"]) {
    Self::Writer
}

Copilot AI changed the title [WIP] Reuse matches_any_ci in AuthorAssociation::parse Deduplicate Rust guard case-insensitive parsing Nov 6, 2026
Copilot AI requested a review from lpcox November 6, 2026 15:09
@lpcox
lpcox marked this pull request as ready for review November 6, 2026 15:21
Copilot AI adaptive review requested due to automatic review settings November 6, 2026 15:21

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

No active review issues are reported for the case-insensitive parsing refactor.

No open issues 🎉

What changed in this PR

This PR reduces duplicated case-insensitive parsing in the Rust GitHub guard’s labeling code, addressing #16068 while preserving existing parsing behavior.

Changes:

  • Share matches_any_ci between author-association and permission parsing.
  • Replace integrity-level parsing branches with a constant lookup table.
  • Extend regression tests for whitespace, empty candidate lists, and normalized integrity round-trips.
File Description
guards/​github-guard/​rust-guard/​src/​labels/​helpers.rs Imports the shared matcher, introduces table-driven integrity parsing, and extends tests.
guards/​github-guard/​rust-guard/​src/​labels/​constants.rs Hosts the shared matcher and reuses it in author-association parsing.

Review effort: Balanced (auto)

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.

[rust-guard] Rust Guard: Reuse matches_any_ci in AuthorAssociation::parse

3 participants