Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix!: Refactor the repository ruleset code #3430

Merged
merged 16 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
58 changes: 29 additions & 29 deletions github/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,177 +480,177 @@
// MarshalJSON is a custom JSON marshaler for RulesetRules.
func (r *RepositoryRulesetRules) MarshalJSON() ([]byte, error) {
// If new rules are added to RulesetRules the capacity needs increasing
arr := make([]json.RawMessage, 0, 21)
rawRules := make([]json.RawMessage, 0, 21)
Copy link
Collaborator

@gmlewis gmlewis Jan 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add a comment here as to why 21 was chosen for the capacity, for the benefit of the maintainers and developers?

If it is completely arbitrary, then please remove it entirely, as that is not idiomatic Go.
The Go team has gone to extensive lengths with benchmarking to make the defaults very reasonable, and if you don't have a good reason for the capacity, then it is not only distracting, but makes the code harder to read and understand, which also violates idiomatic Go, as one of the whole points of Go's design is that it should be super-easy to read and understand.

Therefore, if it is arbitrary, it is idiomatic Go to always take advantage of the zero-value of a type when its initial value is not the focus of the code. Therefore, this would simply be:

  var rawRules []json.RawMessage

Short, sweet, and does not distract the reader into thinking there is something special going on here.
In fact, the comment on 482 is also distracting and reader-time-consuming, in my opinion, if there is nothing special going on here.

However, once again, if the 21 IS important (it is not obvious to me how it possibly could be), then change the comment on 482 to explain why 21 is important. Otherwise, this is just a magic number:
https://en.wikipedia.org/wiki/Magic_number_(programming)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add a comment, but basically there will always be between 1 and 21 items in the slice due to the GitHub data model. My understanding was that if you had prior knowledge on the size of a Go array/slice that you should explicitly set it? If I'm incorrectly informed in this case I'll happily remove the make() call.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, fine, then please change the comment. Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed 2 of the 3 cases as they were incorrect and improved the comment for the case where I think it's worth setting the capacity.


if r.Creation != nil {
bytes, err := marshalRepositoryRulesetRule(RulesetRuleTypeCreation, r.Creation)
if err != nil {
return nil, err
}

Check warning on line 489 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L488-L489

Added lines #L488 - L489 were not covered by tests
arr = append(arr, json.RawMessage(bytes))
rawRules = append(rawRules, json.RawMessage(bytes))
}

if r.Update != nil {
bytes, err := marshalRepositoryRulesetRule(RulesetRuleTypeUpdate, r.Update)
if err != nil {
return nil, err
}

Check warning on line 497 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L496-L497

Added lines #L496 - L497 were not covered by tests
arr = append(arr, json.RawMessage(bytes))
rawRules = append(rawRules, json.RawMessage(bytes))
}

if r.Deletion != nil {
bytes, err := marshalRepositoryRulesetRule(RulesetRuleTypeDeletion, r.Deletion)
if err != nil {
return nil, err
}

Check warning on line 505 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L504-L505

Added lines #L504 - L505 were not covered by tests
arr = append(arr, json.RawMessage(bytes))
rawRules = append(rawRules, json.RawMessage(bytes))
}

if r.RequiredLinearHistory != nil {
bytes, err := marshalRepositoryRulesetRule(RulesetRuleTypeRequiredLinearHistory, r.RequiredLinearHistory)
if err != nil {
return nil, err
}

Check warning on line 513 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L512-L513

Added lines #L512 - L513 were not covered by tests
arr = append(arr, json.RawMessage(bytes))
rawRules = append(rawRules, json.RawMessage(bytes))
}

if r.MergeQueue != nil {
bytes, err := marshalRepositoryRulesetRule(RulesetRuleTypeMergeQueue, r.MergeQueue)
if err != nil {
return nil, err
}

Check warning on line 521 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L520-L521

Added lines #L520 - L521 were not covered by tests
arr = append(arr, json.RawMessage(bytes))
rawRules = append(rawRules, json.RawMessage(bytes))
}

if r.RequiredDeployments != nil {
bytes, err := marshalRepositoryRulesetRule(RulesetRuleTypeRequiredDeployments, r.RequiredDeployments)
if err != nil {
return nil, err
}

Check warning on line 529 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L528-L529

Added lines #L528 - L529 were not covered by tests
arr = append(arr, json.RawMessage(bytes))
rawRules = append(rawRules, json.RawMessage(bytes))
}

if r.RequiredSignatures != nil {
bytes, err := marshalRepositoryRulesetRule(RulesetRuleTypeRequiredSignatures, r.RequiredSignatures)
if err != nil {
return nil, err
}

Check warning on line 537 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L536-L537

Added lines #L536 - L537 were not covered by tests
arr = append(arr, json.RawMessage(bytes))
rawRules = append(rawRules, json.RawMessage(bytes))
}

if r.PullRequest != nil {
bytes, err := marshalRepositoryRulesetRule(RulesetRuleTypePullRequest, r.PullRequest)
if err != nil {
return nil, err
}

Check warning on line 545 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L544-L545

Added lines #L544 - L545 were not covered by tests
arr = append(arr, json.RawMessage(bytes))
rawRules = append(rawRules, json.RawMessage(bytes))
}

if r.RequiredStatusChecks != nil {
bytes, err := marshalRepositoryRulesetRule(RulesetRuleTypeRequiredStatusChecks, r.RequiredStatusChecks)
if err != nil {
return nil, err
}

Check warning on line 553 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L552-L553

Added lines #L552 - L553 were not covered by tests
arr = append(arr, json.RawMessage(bytes))
rawRules = append(rawRules, json.RawMessage(bytes))
}

if r.NonFastForward != nil {
bytes, err := marshalRepositoryRulesetRule(RulesetRuleTypeNonFastForward, r.NonFastForward)
if err != nil {
return nil, err
}

Check warning on line 561 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L560-L561

Added lines #L560 - L561 were not covered by tests
arr = append(arr, json.RawMessage(bytes))
rawRules = append(rawRules, json.RawMessage(bytes))
}

if r.CommitMessagePattern != nil {
bytes, err := marshalRepositoryRulesetRule(RulesetRuleTypeCommitMessagePattern, r.CommitMessagePattern)
if err != nil {
return nil, err
}

Check warning on line 569 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L568-L569

Added lines #L568 - L569 were not covered by tests
arr = append(arr, json.RawMessage(bytes))
rawRules = append(rawRules, json.RawMessage(bytes))
}

if r.CommitAuthorEmailPattern != nil {
bytes, err := marshalRepositoryRulesetRule(RulesetRuleTypeCommitAuthorEmailPattern, r.CommitAuthorEmailPattern)
if err != nil {
return nil, err
}

Check warning on line 577 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L576-L577

Added lines #L576 - L577 were not covered by tests
arr = append(arr, json.RawMessage(bytes))
rawRules = append(rawRules, json.RawMessage(bytes))
}

if r.CommitterEmailPattern != nil {
bytes, err := marshalRepositoryRulesetRule(RulesetRuleTypeCommitterEmailPattern, r.CommitterEmailPattern)
if err != nil {
return nil, err
}

Check warning on line 585 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L584-L585

Added lines #L584 - L585 were not covered by tests
arr = append(arr, json.RawMessage(bytes))
rawRules = append(rawRules, json.RawMessage(bytes))
}

if r.BranchNamePattern != nil {
bytes, err := marshalRepositoryRulesetRule(RulesetRuleTypeBranchNamePattern, r.BranchNamePattern)
if err != nil {
return nil, err
}

Check warning on line 593 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L592-L593

Added lines #L592 - L593 were not covered by tests
arr = append(arr, json.RawMessage(bytes))
rawRules = append(rawRules, json.RawMessage(bytes))
}

if r.TagNamePattern != nil {
bytes, err := marshalRepositoryRulesetRule(RulesetRuleTypeTagNamePattern, r.TagNamePattern)
if err != nil {
return nil, err
}

Check warning on line 601 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L600-L601

Added lines #L600 - L601 were not covered by tests
arr = append(arr, json.RawMessage(bytes))
rawRules = append(rawRules, json.RawMessage(bytes))
}

if r.FilePathRestriction != nil {
bytes, err := marshalRepositoryRulesetRule(RulesetRuleTypeFilePathRestriction, r.FilePathRestriction)
if err != nil {
return nil, err
}

Check warning on line 609 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L608-L609

Added lines #L608 - L609 were not covered by tests
arr = append(arr, json.RawMessage(bytes))
rawRules = append(rawRules, json.RawMessage(bytes))
}

if r.MaxFilePathLength != nil {
bytes, err := marshalRepositoryRulesetRule(RulesetRuleTypeMaxFilePathLength, r.MaxFilePathLength)
if err != nil {
return nil, err
}

Check warning on line 617 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L616-L617

Added lines #L616 - L617 were not covered by tests
arr = append(arr, json.RawMessage(bytes))
rawRules = append(rawRules, json.RawMessage(bytes))
}

if r.FileExtensionRestriction != nil {
bytes, err := marshalRepositoryRulesetRule(RulesetRuleTypeFileExtensionRestriction, r.FileExtensionRestriction)
if err != nil {
return nil, err
}

Check warning on line 625 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L624-L625

Added lines #L624 - L625 were not covered by tests
arr = append(arr, json.RawMessage(bytes))
rawRules = append(rawRules, json.RawMessage(bytes))
}

if r.MaxFileSize != nil {
bytes, err := marshalRepositoryRulesetRule(RulesetRuleTypeMaxFileSize, r.MaxFileSize)
if err != nil {
return nil, err
}

Check warning on line 633 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L632-L633

Added lines #L632 - L633 were not covered by tests
arr = append(arr, json.RawMessage(bytes))
rawRules = append(rawRules, json.RawMessage(bytes))
}

if r.Workflows != nil {
bytes, err := marshalRepositoryRulesetRule(RulesetRuleTypeWorkflows, r.Workflows)
if err != nil {
return nil, err
}

Check warning on line 641 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L640-L641

Added lines #L640 - L641 were not covered by tests
arr = append(arr, json.RawMessage(bytes))
rawRules = append(rawRules, json.RawMessage(bytes))
}

if r.CodeScanning != nil {
bytes, err := marshalRepositoryRulesetRule(RulesetRuleTypeCodeScanning, r.CodeScanning)
if err != nil {
return nil, err
}

Check warning on line 649 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L648-L649

Added lines #L648 - L649 were not covered by tests
arr = append(arr, json.RawMessage(bytes))
rawRules = append(rawRules, json.RawMessage(bytes))
}

return json.Marshal(arr)
return json.Marshal(rawRules)
}

// marshalRepositoryRulesetRule is a helper function to marshal a ruleset rule.
Expand All @@ -666,8 +666,8 @@

bytes, err := json.Marshal(params)
if err != nil {
return nil, err
}

Check warning on line 670 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L669-L670

Added lines #L669 - L670 were not covered by tests

return json.Marshal(repositoryRulesetRuleWrapper{Type: t, Parameters: json.RawMessage(bytes)})
}
Expand All @@ -675,13 +675,13 @@
// UnmarshalJSON is a custom JSON unmarshaler for RulesetRules.
func (r *RepositoryRulesetRules) UnmarshalJSON(data []byte) error {
// If new rules are added to RulesetRules the capacity needs increasing
arr := make([]repositoryRulesetRuleWrapper, 0, 21)
wrappers := make([]repositoryRulesetRuleWrapper, 0, 21)

if err := json.Unmarshal(data, &arr); err != nil {
if err := json.Unmarshal(data, &wrappers); err != nil {
return err
}

Check warning on line 682 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L681-L682

Added lines #L681 - L682 were not covered by tests

for _, w := range arr {
for _, w := range wrappers {
switch w.Type {
case RulesetRuleTypeCreation:
r.Creation = &EmptyRuleParameters{}
Expand All @@ -690,8 +690,8 @@

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

Check warning on line 694 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L693-L694

Added lines #L693 - L694 were not covered by tests
}
case RulesetRuleTypeDeletion:
r.Deletion = &EmptyRuleParameters{}
Expand All @@ -702,16 +702,16 @@

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

Check warning on line 706 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L705-L706

Added lines #L705 - L706 were not covered by tests
}
case RulesetRuleTypeRequiredDeployments:
r.RequiredDeployments = &RequiredDeploymentsRuleParameters{}

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

Check warning on line 714 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L713-L714

Added lines #L713 - L714 were not covered by tests
}
case RulesetRuleTypeRequiredSignatures:
r.RequiredSignatures = &EmptyRuleParameters{}
Expand All @@ -720,16 +720,16 @@

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

Check warning on line 724 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L723-L724

Added lines #L723 - L724 were not covered by tests
}
case RulesetRuleTypeRequiredStatusChecks:
r.RequiredStatusChecks = &RequiredStatusChecksRuleParameters{}

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

Check warning on line 732 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L731-L732

Added lines #L731 - L732 were not covered by tests
}
case RulesetRuleTypeNonFastForward:
r.NonFastForward = &EmptyRuleParameters{}
Expand All @@ -738,88 +738,88 @@

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

Check warning on line 742 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L741-L742

Added lines #L741 - L742 were not covered by tests
}
case RulesetRuleTypeCommitAuthorEmailPattern:
r.CommitAuthorEmailPattern = &PatternRuleParameters{}

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

Check warning on line 750 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L749-L750

Added lines #L749 - L750 were not covered by tests
}
case RulesetRuleTypeCommitterEmailPattern:
r.CommitterEmailPattern = &PatternRuleParameters{}

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

Check warning on line 758 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L757-L758

Added lines #L757 - L758 were not covered by tests
}
case RulesetRuleTypeBranchNamePattern:
r.BranchNamePattern = &PatternRuleParameters{}

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

Check warning on line 766 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L765-L766

Added lines #L765 - L766 were not covered by tests
}
case RulesetRuleTypeTagNamePattern:
r.TagNamePattern = &PatternRuleParameters{}

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

Check warning on line 774 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L773-L774

Added lines #L773 - L774 were not covered by tests
}
case RulesetRuleTypeFilePathRestriction:
r.FilePathRestriction = &FilePathRestrictionRuleParameters{}

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

Check warning on line 782 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L781-L782

Added lines #L781 - L782 were not covered by tests
}
case RulesetRuleTypeMaxFilePathLength:
r.MaxFilePathLength = &MaxFilePathLengthRuleParameters{}

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

Check warning on line 790 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L789-L790

Added lines #L789 - L790 were not covered by tests
}
case RulesetRuleTypeFileExtensionRestriction:
r.FileExtensionRestriction = &FileExtensionRestrictionRuleParameters{}

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

Check warning on line 798 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L797-L798

Added lines #L797 - L798 were not covered by tests
}
case RulesetRuleTypeMaxFileSize:
r.MaxFileSize = &MaxFileSizeRuleParameters{}

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

Check warning on line 806 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L805-L806

Added lines #L805 - L806 were not covered by tests
}
case RulesetRuleTypeWorkflows:
r.Workflows = &WorkflowsRuleParameters{}

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

Check warning on line 814 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L813-L814

Added lines #L813 - L814 were not covered by tests
}
case RulesetRuleTypeCodeScanning:
r.CodeScanning = &CodeScanningRuleParameters{}

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

Check warning on line 822 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L821-L822

Added lines #L821 - L822 were not covered by tests
}
}
}
Expand All @@ -837,13 +837,13 @@
// UnmarshalJSON is a custom JSON unmarshaler for BranchRules.
func (r *BranchRules) UnmarshalJSON(data []byte) error {
// If new rules are added to RulesetRules the capacity needs increasing
arr := make([]branchRuleWrapper, 0, 21)
wrappers := make([]branchRuleWrapper, 0, 21)

if err := json.Unmarshal(data, &arr); err != nil {
if err := json.Unmarshal(data, &wrappers); err != nil {
return err
}

Check warning on line 844 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L843-L844

Added lines #L843 - L844 were not covered by tests

for _, w := range arr {
for _, w := range wrappers {
switch w.Type {
case RulesetRuleTypeCreation:
r.Creation = append(r.Creation, &BranchRuleMetadata{RulesetSourceType: w.RulesetSourceType, RulesetSource: w.RulesetSource, RulesetID: w.RulesetID})
Expand All @@ -852,8 +852,8 @@

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

Check warning on line 856 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L855-L856

Added lines #L855 - L856 were not covered by tests
}

r.Update = append(r.Update, &UpdateBranchRule{BranchRuleMetadata: w.BranchRuleMetadata, Parameters: *params})
Expand All @@ -866,8 +866,8 @@

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

Check warning on line 870 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L869-L870

Added lines #L869 - L870 were not covered by tests
}

r.MergeQueue = append(r.MergeQueue, &MergeQueueBranchRule{BranchRuleMetadata: w.BranchRuleMetadata, Parameters: *params})
Expand All @@ -876,8 +876,8 @@

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

Check warning on line 880 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L879-L880

Added lines #L879 - L880 were not covered by tests
}

r.RequiredDeployments = append(r.RequiredDeployments, &RequiredDeploymentsBranchRule{BranchRuleMetadata: w.BranchRuleMetadata, Parameters: *params})
Expand All @@ -888,8 +888,8 @@

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

Check warning on line 892 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L891-L892

Added lines #L891 - L892 were not covered by tests
}

r.PullRequest = append(r.PullRequest, &PullRequestBranchRule{BranchRuleMetadata: w.BranchRuleMetadata, Parameters: *params})
Expand All @@ -898,8 +898,8 @@

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

Check warning on line 902 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L901-L902

Added lines #L901 - L902 were not covered by tests
}

r.RequiredStatusChecks = append(r.RequiredStatusChecks, &RequiredStatusChecksBranchRule{BranchRuleMetadata: w.BranchRuleMetadata, Parameters: *params})
Expand All @@ -910,8 +910,8 @@

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

Check warning on line 914 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L913-L914

Added lines #L913 - L914 were not covered by tests
}

r.CommitMessagePattern = append(r.CommitMessagePattern, &PatternBranchRule{BranchRuleMetadata: w.BranchRuleMetadata, Parameters: *params})
Expand All @@ -920,8 +920,8 @@

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

Check warning on line 924 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L923-L924

Added lines #L923 - L924 were not covered by tests
}

r.CommitAuthorEmailPattern = append(r.CommitAuthorEmailPattern, &PatternBranchRule{BranchRuleMetadata: w.BranchRuleMetadata, Parameters: *params})
Expand All @@ -930,8 +930,8 @@

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

Check warning on line 934 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L933-L934

Added lines #L933 - L934 were not covered by tests
}

r.CommitterEmailPattern = append(r.CommitterEmailPattern, &PatternBranchRule{BranchRuleMetadata: w.BranchRuleMetadata, Parameters: *params})
Expand All @@ -940,8 +940,8 @@

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

Check warning on line 944 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L943-L944

Added lines #L943 - L944 were not covered by tests
}

r.BranchNamePattern = append(r.BranchNamePattern, &PatternBranchRule{BranchRuleMetadata: w.BranchRuleMetadata, Parameters: *params})
Expand All @@ -950,8 +950,8 @@

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

Check warning on line 954 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L953-L954

Added lines #L953 - L954 were not covered by tests
}

r.TagNamePattern = append(r.TagNamePattern, &PatternBranchRule{BranchRuleMetadata: w.BranchRuleMetadata, Parameters: *params})
Expand All @@ -960,8 +960,8 @@

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

Check warning on line 964 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L963-L964

Added lines #L963 - L964 were not covered by tests
}

r.FilePathRestriction = append(r.FilePathRestriction, &FilePathRestrictionBranchRule{BranchRuleMetadata: w.BranchRuleMetadata, Parameters: *params})
Expand All @@ -970,8 +970,8 @@

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

Check warning on line 974 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L973-L974

Added lines #L973 - L974 were not covered by tests
}

r.MaxFilePathLength = append(r.MaxFilePathLength, &MaxFilePathLengthBranchRule{BranchRuleMetadata: w.BranchRuleMetadata, Parameters: *params})
Expand All @@ -980,8 +980,8 @@

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

Check warning on line 984 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L983-L984

Added lines #L983 - L984 were not covered by tests
}

r.FileExtensionRestriction = append(r.FileExtensionRestriction, &FileExtensionRestrictionBranchRule{BranchRuleMetadata: w.BranchRuleMetadata, Parameters: *params})
Expand All @@ -990,8 +990,8 @@

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

Check warning on line 994 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L993-L994

Added lines #L993 - L994 were not covered by tests
}

r.MaxFileSize = append(r.MaxFileSize, &MaxFileSizeBranchRule{BranchRuleMetadata: w.BranchRuleMetadata, Parameters: *params})
Expand All @@ -1000,8 +1000,8 @@

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

Check warning on line 1004 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L1003-L1004

Added lines #L1003 - L1004 were not covered by tests
}

r.Workflows = append(r.Workflows, &WorkflowsBranchRule{BranchRuleMetadata: w.BranchRuleMetadata, Parameters: *params})
Expand All @@ -1010,8 +1010,8 @@

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

Check warning on line 1014 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L1013-L1014

Added lines #L1013 - L1014 were not covered by tests
}

r.CodeScanning = append(r.CodeScanning, &CodeScanningBranchRule{BranchRuleMetadata: w.BranchRuleMetadata, Parameters: *params})
Expand All @@ -1026,8 +1026,8 @@
w := repositoryRulesetRuleWrapper{}

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

Check warning on line 1030 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L1029-L1030

Added lines #L1029 - L1030 were not covered by tests

r.Type = w.Type

Expand All @@ -1039,8 +1039,8 @@

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

Check warning on line 1043 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L1042-L1043

Added lines #L1042 - L1043 were not covered by tests
}

r.Parameters = p
Expand All @@ -1053,8 +1053,8 @@

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

Check warning on line 1057 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L1056-L1057

Added lines #L1056 - L1057 were not covered by tests
}

r.Parameters = p
Expand All @@ -1063,8 +1063,8 @@

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

Check warning on line 1067 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L1066-L1067

Added lines #L1066 - L1067 were not covered by tests
}

r.Parameters = p
Expand All @@ -1075,8 +1075,8 @@

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

Check warning on line 1079 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L1078-L1079

Added lines #L1078 - L1079 were not covered by tests
}

r.Parameters = p
Expand All @@ -1085,8 +1085,8 @@

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

Check warning on line 1089 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L1088-L1089

Added lines #L1088 - L1089 were not covered by tests
}

r.Parameters = p
Expand All @@ -1097,8 +1097,8 @@

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

Check warning on line 1101 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L1100-L1101

Added lines #L1100 - L1101 were not covered by tests
}

r.Parameters = p
Expand All @@ -1107,8 +1107,8 @@

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

Check warning on line 1111 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L1110-L1111

Added lines #L1110 - L1111 were not covered by tests
}

r.Parameters = p
Expand All @@ -1117,8 +1117,8 @@

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

Check warning on line 1121 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L1120-L1121

Added lines #L1120 - L1121 were not covered by tests
}

r.Parameters = p
Expand All @@ -1127,8 +1127,8 @@

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

Check warning on line 1131 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L1130-L1131

Added lines #L1130 - L1131 were not covered by tests
}

r.Parameters = p
Expand All @@ -1137,8 +1137,8 @@

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

Check warning on line 1141 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L1140-L1141

Added lines #L1140 - L1141 were not covered by tests
}

r.Parameters = p
Expand All @@ -1147,8 +1147,8 @@

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

Check warning on line 1151 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L1150-L1151

Added lines #L1150 - L1151 were not covered by tests
}

r.Parameters = p
Expand All @@ -1157,8 +1157,8 @@

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

Check warning on line 1161 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L1160-L1161

Added lines #L1160 - L1161 were not covered by tests
}

r.Parameters = p
Expand All @@ -1167,8 +1167,8 @@

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

Check warning on line 1171 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L1170-L1171

Added lines #L1170 - L1171 were not covered by tests
}

r.Parameters = p
Expand All @@ -1177,8 +1177,8 @@

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

Check warning on line 1181 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L1180-L1181

Added lines #L1180 - L1181 were not covered by tests
}

r.Parameters = p
Expand All @@ -1187,8 +1187,8 @@

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

Check warning on line 1191 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L1190-L1191

Added lines #L1190 - L1191 were not covered by tests
}

r.Parameters = p
Expand All @@ -1197,8 +1197,8 @@

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

Check warning on line 1201 in github/rules.go

View check run for this annotation

Codecov / codecov/patch

github/rules.go#L1200-L1201

Added lines #L1200 - L1201 were not covered by tests
}

r.Parameters = p
Expand Down
Loading
Loading