Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion github/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ type BranchRules struct {
TagNamePattern []*PatternBranchRule
Workflows []*WorkflowsBranchRule
CodeScanning []*CodeScanningBranchRule
CopilotCodeReview []*CopilotCodeReviewBranchRule

// Push target rules.
FileExtensionRestriction []*FileExtensionRestrictionBranchRule
Expand Down Expand Up @@ -431,6 +432,12 @@ type CodeScanningBranchRule struct {
Parameters CodeScanningRuleParameters `json:"parameters"`
}

// CopilotCodeReviewBranchRule represents a copilot code review branch rule.
type CopilotCodeReviewBranchRule struct {
BranchRuleMetadata
Parameters CopilotCodeReviewRuleParameters `json:"parameters"`
}

// EmptyRuleParameters represents the parameters for a rule with no options.
type EmptyRuleParameters struct{}

Expand Down Expand Up @@ -542,7 +549,7 @@ type CodeScanningRuleParameters struct {

// CopilotCodeReviewRuleParameters represents the copilot_code_review rule parameters.
type CopilotCodeReviewRuleParameters struct {
ReviewNewPushes bool `json:"review_new_pushes"`
ReviewOnPush bool `json:"review_on_push"`
ReviewDraftPullRequests bool `json:"review_draft_pull_requests"`
}

Expand Down Expand Up @@ -1203,6 +1210,16 @@ func (r *BranchRules) UnmarshalJSON(data []byte) error {
}

r.CodeScanning = append(r.CodeScanning, &CodeScanningBranchRule{BranchRuleMetadata: w.BranchRuleMetadata, Parameters: *params})
case RulesetRuleTypeCopilotCodeReview:
params := &CopilotCodeReviewRuleParameters{}

if w.Parameters != nil {
if err := json.Unmarshal(w.Parameters, params); err != nil {
return err
}
}

r.CopilotCodeReview = append(r.CopilotCodeReview, &CopilotCodeReviewBranchRule{BranchRuleMetadata: w.BranchRuleMetadata, Parameters: *params})
}
}

Expand Down
Loading
Loading