From 06d5a7249c6394eb407e313cd48028b24a9d0674 Mon Sep 17 00:00:00 2001 From: Clemens W Date: Thu, 24 Oct 2024 15:52:54 +0200 Subject: [PATCH] add fix for source in repo prop --- github/github-accessors.go | 8 ++++++++ github/github-accessors_test.go | 11 +++++++++++ github/orgs_rules_test.go | 13 +++++-------- github/repos_rules.go | 2 +- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/github/github-accessors.go b/github/github-accessors.go index f3a16c10ae1..7c89610ae29 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -21270,6 +21270,14 @@ func (r *RulesetRepositoryNamesConditionParameters) GetProtected() bool { return *r.Protected } +// GetSource returns the Source field if it's non-nil, zero value otherwise. +func (r *RulesetRepositoryPropertyTargetParameters) GetSource() string { + if r == nil || r.Source == nil { + return "" + } + return *r.Source +} + // GetBusy returns the Busy field if it's non-nil, zero value otherwise. func (r *Runner) GetBusy() bool { if r == nil || r.Busy == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 2086baa0fda..26f540ec702 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -27355,6 +27355,17 @@ func TestRulesetRepositoryNamesConditionParameters_GetProtected(tt *testing.T) { r.GetProtected() } +func TestRulesetRepositoryPropertyTargetParameters_GetSource(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &RulesetRepositoryPropertyTargetParameters{Source: &zeroValue} + r.GetSource() + r = &RulesetRepositoryPropertyTargetParameters{} + r.GetSource() + r = nil + r.GetSource() +} + func TestRunner_GetBusy(tt *testing.T) { tt.Parallel() var zeroValue bool diff --git a/github/orgs_rules_test.go b/github/orgs_rules_test.go index 66cf6bd5c80..bb2048cb0ed 100644 --- a/github/orgs_rules_test.go +++ b/github/orgs_rules_test.go @@ -424,7 +424,6 @@ func TestOrganizationsService_CreateOrganizationRuleset_RepoProperty(t *testing. "exclude": [ { "name": "testExcludeProp", - "source": "custom", "property_values": [ "false" ] @@ -548,14 +547,13 @@ func TestOrganizationsService_CreateOrganizationRuleset_RepoProperty(t *testing. Include: []RulesetRepositoryPropertyTargetParameters{ { Name: "testIncludeProp", - Source: "custom", + Source: String("custom"), Values: []string{"true"}, }, }, Exclude: []RulesetRepositoryPropertyTargetParameters{ { Name: "testExcludeProp", - Source: "custom", Values: []string{"false"}, }, }, @@ -641,14 +639,13 @@ func TestOrganizationsService_CreateOrganizationRuleset_RepoProperty(t *testing. Include: []RulesetRepositoryPropertyTargetParameters{ { Name: "testIncludeProp", - Source: "custom", + Source: String("custom"), Values: []string{"true"}, }, }, Exclude: []RulesetRepositoryPropertyTargetParameters{ { Name: "testExcludeProp", - Source: "custom", Values: []string{"false"}, }, }, @@ -1197,7 +1194,7 @@ func TestOrganizationsService_GetOrganizationRulesetWithRepoPropCondition(t *tes Include: []RulesetRepositoryPropertyTargetParameters{ { Name: "testIncludeProp", - Source: "custom", + Source: String("custom"), Values: []string{"true"}, }, }, @@ -1390,7 +1387,7 @@ func TestOrganizationsService_UpdateOrganizationRulesetWithRepoProp(t *testing.T Include: []RulesetRepositoryPropertyTargetParameters{ { Name: "testIncludeProp", - Source: "custom", + Source: String("custom"), Values: []string{"true"}, }, }, @@ -1422,7 +1419,7 @@ func TestOrganizationsService_UpdateOrganizationRulesetWithRepoProp(t *testing.T Include: []RulesetRepositoryPropertyTargetParameters{ { Name: "testIncludeProp", - Source: "custom", + Source: String("custom"), Values: []string{"true"}, }, }, diff --git a/github/repos_rules.go b/github/repos_rules.go index ca9e9ea85bc..44846cf7c9e 100644 --- a/github/repos_rules.go +++ b/github/repos_rules.go @@ -52,7 +52,7 @@ type RulesetRepositoryIDsConditionParameters struct { type RulesetRepositoryPropertyTargetParameters struct { Name string `json:"name"` Values []string `json:"property_values"` - Source string `json:"source"` + Source *string `json:"source,omitempty"` } // RulesetRepositoryPropertyConditionParameters represents the conditions object for repository_property.