rust-guard: deduplicate repo fallback resolution and private-flag field checks#7988
Merged
Merged
Conversation
Copilot
AI
changed the title
[WIP] Extract default_repo_for_items helper to reduce code duplication
rust-guard: deduplicate repo fallback resolution and private-flag field checks
Jun 23, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the Rust GitHub guard labeling code to remove duplicated “default repo” fallback logic in path-based response labeling, and to consolidate repeated “private” field probing in repo objects—keeping behavior consistent while reducing maintenance overhead.
Changes:
- Extracted
default_repo_for_items(...)and reused it across the collection labelers that previously reimplemented the same fallback logic. - Simplified
private_flag_from_repo_object(...)to iterate through the known candidate boolean fields (private,is_private,isPrivate) before falling back tovisibilityhandling. - Updated the affected tool handler branches to use the shared helpers without changing labeling semantics.
Show a summary per file
| File | Description |
|---|---|
| guards/github-guard/rust-guard/src/labels/response_paths.rs | Deduplicates default-repo fallback resolution used by multiple collection labeling paths. |
| guards/github-guard/rust-guard/src/labels/backend.rs | Consolidates private-flag detection by probing candidate field names in a single loop. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 0
This was referenced Jun 24, 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.
response_paths.rsduplicated the same default-repo fallback logic across four tool handlers, andbackend.rsrepeated equivalentprivatefield probing logic in three separate blocks. This PR consolidates both patterns into single reusable paths while preserving behavior.response_paths.rs: extract shared default repo resolverdefault_repo_for_items(arg_repo_full: String, items: &[Value]) -> String.list_pull_requestslist_issueslist_commitslist_releasesbackend.rs: collapse repeated private-field probesprivate_flag_from_repo_objectto iterate candidate field names in order:"private","is_private","isPrivate"visibilityfallback logic unchanged.Resulting code shape (representative)