Skip to content

Commit 25664d0

Browse files
committed
Enable looking up parent rules
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) <puerco@carabiner.dev>
1 parent 3253aaf commit 25664d0

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

sourcetool/pkg/ghcontrol/checklevel.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,14 @@ 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

106+
// fmt.Printf("Salio: %+v", oldestDeletion)
107+
106108
oldestNoFf, err := ghc.getOldestActiveRule(ctx, rules.NonFastForward)
107109
if err != nil {
108-
return nil, err
110+
return nil, fmt.Errorf("looking for oldest push protection rule: %w", err)
109111
}
110112

111113
if oldestDeletion == nil || oldestNoFf == nil {
@@ -315,7 +317,7 @@ func (ghc *GitHubConnection) EnableTagRules(ctx context.Context) error {
315317
func (ghc *GitHubConnection) getOldestActiveRule(ctx context.Context, rules []*github.BranchRuleMetadata) (*github.RepositoryRuleset, error) {
316318
var oldestActive *github.RepositoryRuleset
317319
for _, rule := range rules {
318-
ruleset, _, err := ghc.Client().Repositories.GetRuleset(ctx, ghc.Owner(), ghc.Repo(), rule.RulesetID, false)
320+
ruleset, _, err := ghc.Client().Repositories.GetRuleset(ctx, ghc.Owner(), ghc.Repo(), rule.RulesetID, true)
319321
if err != nil {
320322
return nil, err
321323
}

0 commit comments

Comments
 (0)