[rust-guard] Deduplicate item_number extraction and add direct commit_integrity coverage#7577
Merged
Merged
Conversation
Copilot
AI
changed the title
[WIP] Extract item_number helper to eliminate 9x duplication in helpers.rs
[rust-guard] Deduplicate Jun 15, 2026
item_number extraction and add direct commit_integrity coverage
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the Rust guard labeling helpers to remove repeated JSON extraction logic for issue/PR numbers in integrity-related logging, and adds direct unit tests for commit_integrity to cover key decision paths that affect integrity labeling.
Changes:
- Added a private
item_number(&Value) -> u64helper to centralizenumberextraction for logging use cases. - Replaced nine duplicated
numberextraction chains across integrity promotion/demotion and logging paths withitem_number(item). - Added unit tests that directly exercise
commit_integrityoutcomes across blocked-author, repo privacy, default-branch, and owner-authored scenarios.
Show a summary per file
| File | Description |
|---|---|
| guards/github-guard/rust-guard/src/labels/helpers.rs | Deduplicates number extraction for logging and adds focused unit tests covering commit_integrity decision branches. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 0
This was referenced Jun 15, 2026
This was referenced Jun 16, 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.
helpers.rsrepeated the samenumberextraction chain in nine integrity/logging paths, andcommit_integrityhad no direct unit coverage despite enforcing multiple security-critical integrity floors/elevations.Refactor: centralized issue/PR number extraction
helpers.rs:item_number(item: &Value) -> u64numberextraction sites (approval/promotion/demotion adjustments plus PR/issue blocked and collaborator-fallback logging paths) withitem_number(item).Tests: direct coverage for
commit_integritydecision pathshelpers.rsfor:Example (deduped call site pattern)