[rust-guard] Hoist commit SHA extraction in commit_integrity and add default-branch commit-context coverage#7939
Merged
Conversation
Copilot
AI
changed the title
[WIP] Hoist
[rust-guard] Hoist commit SHA extraction in Jun 22, 2026
sha/short_sha in commit_integrity and add testscommit_integrity and add default-branch commit-context coverage
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors Rust guard integrity labeling logic to reduce duplication in commit_integrity, and adds unit coverage for the “default-branch commit context” classifier that influences merged-level integrity decisions.
Changes:
- Hoists commit
shaand derivedshort_shacomputation to a single binding incommit_integrityand reuses it for blocked-user logging and collaborator-permission fallback context formatting. - Adds focused unit tests for
is_default_branch_commit_context/looks_like_commit_sha, covering empty refs, default branch names (main/master/HEAD, case-insensitive),get_commitSHA handling (7..=40 hex), and rejection of non-hex / too-short / too-long inputs.
Show a summary per file
| File | Description |
|---|---|
| guards/github-guard/rust-guard/src/labels/helpers.rs | Deduplicates SHA handling in commit_integrity and adds targeted tests for default-branch commit-context classification edge cases. |
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 22, 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.
commit_integrityduplicatedsha/short_shaextraction in two branches, andis_default_branch_commit_context(including SHA-shape handling) had no direct unit coverage despite gating merged-level integrity decisions.This PR removes the duplication and adds focused tests for the
get_commitSHA path and SHA/ref edge cases.Refactor:
commit_integritySHA handlingshaandshort_shacomputation to a single binding at function entry.short_shain both:repo@short_sha)Coverage: default-branch commit context classification
is_default_branch_commit_contextbehavior:main/master/HEAD(case-insensitive) as default-branch contextget_commit+ valid SHA (7..=40 hex) treated as default-branch contextlist_commits+ SHA not treated as default-branch context