File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -580,9 +580,7 @@ type repositoryRulesetRuleWrapper struct {
580580
581581// MarshalJSON is a custom JSON marshaler for RulesetRules.
582582func (r * RepositoryRulesetRules ) MarshalJSON () ([]byte , error ) {
583- // The RepositoryRulesetRules type marshals to between 1 and 22 rules.
584- // If new rules are added to RepositoryRulesetRules the capacity below needs increasing
585- rawRules := make ([]json.RawMessage , 0 , 22 )
583+ var rawRules []json.RawMessage
586584
587585 if r .Creation != nil {
588586 bytes , err := marshalRepositoryRulesetRule (RulesetRuleTypeCreation , r .Creation )
@@ -800,6 +798,10 @@ func (r *RepositoryRulesetRules) MarshalJSON() ([]byte, error) {
800798 rawRules = append (rawRules , json .RawMessage (bytes ))
801799 }
802800
801+ if len (rawRules ) == 0 {
802+ return []byte ("[]" ), nil
803+ }
804+
803805 return json .Marshal (rawRules )
804806}
805807
You can’t perform that action at this time.
0 commit comments