feat: recognize rulesets in branch protection#842
Open
bmendonca3 wants to merge 1 commit into
Open
Conversation
Signed-off-by: bmendonca3 <208517100+bmendonca3@users.noreply.github.com>
justaugustus
left a comment
Member
There was a problem hiding this comment.
See note about AI contributions —> #841 (comment)
|
This pull request has been marked stale because it has been open for 10 days with no activity |
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.
Summary
Adds Check-only Repository Rulesets support to the existing Branch Protection policy.
This keeps the existing classic branch protection behavior, but when a branch is missing or incomplete under classic branch protection, Allstar also checks the active rules returned by
Repositories.GetRulesForBranch.The policy now recognizes direct ruleset equivalents for:
This intentionally does not add Fix/CRUD support for rulesets. The existing
fixaction still updates classic branch protection only.Fixes #475
Testing
PATH=/tmp/go/bin:$PATH go test ./pkg/policies/branchPATH=/tmp/go/bin:$PATH go test ./pkg/policies/...PATH=/tmp/go/bin:$PATH go test ./...PATH=/tmp/go/bin:$PATH go vet ./...PATH=/tmp/go/bin:$PATH go build ./...PATH=/tmp/go/bin:$PATH /tmp/go-tools/golangci-lint run --timeout 5m --verbosegit diff --checkLive validation
Validated against a disposable public repository:
https://github.com/bmendonca3/allstar-rulesets-validation-20260528154925
Before creating a ruleset:
pull_request=0 status_checks=0 non_fast_forward=0 required_signatures=0enabled=true pass=falseNo protection found for branch mainAfter creating an active ruleset for
mainwith pull request review and non-fast-forward rules:pull_request=1 status_checks=0 non_fast_forward=1 required_signatures=0enabled=true pass=trueScope note
Rulesets are not used to satisfy
enforceOnAdmins, because rulesets model bypass behavior differently than classic branch protection.