Skip to content

Commit 3506901

Browse files
authored
Enable looking up parent rules (#248)
This PR changes the API query to allow the client to look for the ContinuityControl controls in parent rules as well. Signed-off-by: Adolfo García Veytia (Puerco) <[email protected]>
1 parent 3253aaf commit 3506901

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

sourcetool/pkg/ghcontrol/checklevel.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,12 @@ func (ghc *GitHubConnection) ruleMeetsRequiresReview(rule *github.PullRequestBra
100100
func (ghc *GitHubConnection) computeContinuityControl(ctx context.Context, rules *github.BranchRules) (*provenance.Control, error) {
101101
oldestDeletion, err := ghc.getOldestActiveRule(ctx, rules.Deletion)
102102
if err != nil {
103-
return nil, err
103+
return nil, fmt.Errorf("looking for oldest branch delete protection: %w", err)
104104
}
105105

106106
oldestNoFf, err := ghc.getOldestActiveRule(ctx, rules.NonFastForward)
107107
if err != nil {
108-
return nil, err
108+
return nil, fmt.Errorf("looking for oldest push protection rule: %w", err)
109109
}
110110

111111
if oldestDeletion == nil || oldestNoFf == nil {
@@ -315,7 +315,7 @@ func (ghc *GitHubConnection) EnableTagRules(ctx context.Context) error {
315315
func (ghc *GitHubConnection) getOldestActiveRule(ctx context.Context, rules []*github.BranchRuleMetadata) (*github.RepositoryRuleset, error) {
316316
var oldestActive *github.RepositoryRuleset
317317
for _, rule := range rules {
318-
ruleset, _, err := ghc.Client().Repositories.GetRuleset(ctx, ghc.Owner(), ghc.Repo(), rule.RulesetID, false)
318+
ruleset, _, err := ghc.Client().Repositories.GetRuleset(ctx, ghc.Owner(), ghc.Repo(), rule.RulesetID, true)
319319
if err != nil {
320320
return nil, err
321321
}

0 commit comments

Comments
 (0)