Repository navigation
Deduplicate Rust guard repo lookups and borrow scope fields - #16021
Merged
Merged
Conversation
Co-authored-by: lpcox <[email protected]>
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
lpcox
marked this pull request as ready for review
November 5, 2026 15:59
Contributor
There was a problem hiding this comment.
🟢 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_nameand 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)
This was referenced Nov 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Repository extraction repeats lookup chains, while scope alias resolution allocates temporary strings. This refactor reduces duplication and allocations without changing scope selection.
pr_side_full_nameand consolidate conversion toString, preserving lookup precedence and URL fallback.&strvalues, includinglevel; allocate only when storing a non-empty baseline scope inCow::Owned.