Skip to content

Deduplicate Rust guard repo lookups and borrow scope fields - #16021

Merged
lpcox merged 2 commits into
mainfrom
copilot/rust-guard-dedupe-repo-lookups
Nov 5, 2026
Merged

lpcox merged 2 commits into
mainfrom
copilot/rust-guard-dedupe-repo-lookups

Conversation

Copilot AI commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Repository extraction repeats lookup chains, while scope alias resolution allocates temporary strings. This refactor reduces duplication and allocations without changing scope selection.

  • Repository lookup: Reuse pr_side_full_name and consolidate conversion to String, preserving lookup precedence and URL fallback.
  • Scope extraction: Return borrowed &str values, including level; allocate only when storing a non-empty baseline scope in Cow::Owned.
  • Regression coverage: Check lookup precedence, empty and malformed fields, and borrowed-string identity.

Copilot AI changed the title [WIP] Refactor extract_repo_from_item to deduplicate lookups Deduplicate Rust guard repo lookups and borrow scope fields Nov 5, 2026
Copilot AI requested a review from lpcox November 5, 2026 15:51
@lpcox
lpcox marked this pull request as ready for review November 5, 2026 15:59
Copilot AI adaptive review requested due to automatic review settings November 5, 2026 15:59

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

There are no active review issues for the repository and scope extraction refactor.

No open issues 🎉

What changed in this PR

Refactors repository and scope extraction in the Rust GitHub guard to reduce duplication and temporary allocations while preserving lookup precedence and scope selection.

Changes:

  • Reuses pr_side_full_name and consolidates repository-name conversion, retaining URL fallback.
  • Borrows scope fields as &str, allocating when storing a non-empty baseline scope.
  • Adds regression tests for lookup ordering, empty and malformed fields, and borrowed-string identity.
File Description
guards/​github-guard/​rust-guard/​src/​labels/​tool_rules.rs Borrows scope fields, updates callers, and tests alias selection and string identity.
guards/​github-guard/​rust-guard/​src/​labels/​helpers.rs Consolidates repository lookups and tests precedence, URL fallback, and empty names.

Review effort: Balanced (auto)

@lpcox
lpcox merged commit 0e05b22 into main Nov 5, 2026
53 of 54 checks passed
@lpcox
lpcox deleted the copilot/rust-guard-dedupe-repo-lookups branch November 5, 2026 16:16
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: dedupe extract_repo_from_item lookups and avoid allocs in get_first_non_empty_field

3 participants