From 2a56435d05d12695303f357ea059c3e87f004d6a Mon Sep 17 00:00:00 2001 From: Matthew Reidy Date: Wed, 17 Apr 2024 16:46:01 -0700 Subject: [PATCH 01/15] work done on merge queue addition --- github/repos_rules.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/github/repos_rules.go b/github/repos_rules.go index 34711dda979..a25d03b3269 100644 --- a/github/repos_rules.go +++ b/github/repos_rules.go @@ -110,6 +110,13 @@ type RequiredWorkflowsRuleParameters struct { RequiredWorkflows []*RuleRequiredWorkflow `json:"workflows"` } +type RuleMergeQueue struct { +} + +// RequiredWorkflowsRuleParameters represents the workflows rule parameters. +type MergeQueueRuleParameters struct { +} + // RepositoryRule represents a GitHub Rule. type RepositoryRule struct { Type string `json:"type"` @@ -200,6 +207,16 @@ func (r *RepositoryRule) UnmarshalJSON(data []byte) error { bytes, _ := json.Marshal(params) rawParams := json.RawMessage(bytes) + r.Parameters = &rawParams + case "merge_queue": + params := MergeQueueRuleParameters{} + if err := json.Unmarshal(*RepositoryRule.Parameters, ¶ms); err != nil { + return err + } + + bytes, _ := json.Marshal(params) + rawParams := json.RawMessage(bytes) + r.Parameters = &rawParams default: r.Type = "" @@ -210,6 +227,18 @@ func (r *RepositoryRule) UnmarshalJSON(data []byte) error { return nil } +// NewMergeQueueRule creates a rule to only allow users with bypass permission to create matching refs. +func NewMergeQueueRule(params *RequiredStatusChecksRuleParameters) (rule *RepositoryRule) { + bytes, _ := json.Marshal(params) + + rawParams := json.RawMessage(bytes) + + return &RepositoryRule{ + Type: "merge_queue", + Parameters: &rawParams, + } +} + // NewCreationRule creates a rule to only allow users with bypass permission to create matching refs. func NewCreationRule() (rule *RepositoryRule) { return &RepositoryRule{ From ff1530234676e6ceb0dec9bf21711685b9a043a2 Mon Sep 17 00:00:00 2001 From: Matthew Reidy Date: Thu, 18 Apr 2024 10:07:03 -0700 Subject: [PATCH 02/15] added support for merge queue, altered tests to include merge queue --- AUTHORS | 1 + github/orgs_rules_test.go | 10 ++++++++++ github/repos_rules.go | 27 +++------------------------ github/repos_rules_test.go | 7 +++++++ 4 files changed, 21 insertions(+), 24 deletions(-) diff --git a/AUTHORS b/AUTHORS index 74a21dc604e..01f3f6a3d12 100644 --- a/AUTHORS +++ b/AUTHORS @@ -485,3 +485,4 @@ zhouhaibing089 六开箱 缘生 蒋航 +Matthew Reidy \ No newline at end of file diff --git a/github/orgs_rules_test.go b/github/orgs_rules_test.go index 50ba4e20c01..0ed54ca8d27 100644 --- a/github/orgs_rules_test.go +++ b/github/orgs_rules_test.go @@ -123,6 +123,9 @@ func TestOrganizationsService_CreateOrganizationRuleset_RepoNames(t *testing.T) { "type": "deletion" }, + { + "type": "merge_queue" + }, { "type": "required_linear_history" }, @@ -238,6 +241,7 @@ func TestOrganizationsService_CreateOrganizationRuleset_RepoNames(t *testing.T) UpdateAllowsFetchAndMerge: true, }), NewDeletionRule(), + NewMergeQueueRule(), NewRequiredLinearHistoryRule(), NewRequiredDeploymentsRule(&RequiredDeploymentEnvironmentsRuleParameters{ RequiredDeploymentEnvironments: []string{"test"}, @@ -324,6 +328,7 @@ func TestOrganizationsService_CreateOrganizationRuleset_RepoNames(t *testing.T) UpdateAllowsFetchAndMerge: true, }), NewDeletionRule(), + NewMergeQueueRule(), NewRequiredLinearHistoryRule(), NewRequiredDeploymentsRule(&RequiredDeploymentEnvironmentsRuleParameters{ RequiredDeploymentEnvironments: []string{"test"}, @@ -437,6 +442,9 @@ func TestOrganizationsService_CreateOrganizationRuleset_RepoIDs(t *testing.T) { { "type": "deletion" }, + { + "type": "merge_queue" + }, { "type": "required_linear_history" }, @@ -550,6 +558,7 @@ func TestOrganizationsService_CreateOrganizationRuleset_RepoIDs(t *testing.T) { UpdateAllowsFetchAndMerge: true, }), NewDeletionRule(), + NewMergeQueueRule(), NewRequiredLinearHistoryRule(), NewRequiredDeploymentsRule(&RequiredDeploymentEnvironmentsRuleParameters{ RequiredDeploymentEnvironments: []string{"test"}, @@ -634,6 +643,7 @@ func TestOrganizationsService_CreateOrganizationRuleset_RepoIDs(t *testing.T) { UpdateAllowsFetchAndMerge: true, }), NewDeletionRule(), + NewMergeQueueRule(), NewRequiredLinearHistoryRule(), NewRequiredDeploymentsRule(&RequiredDeploymentEnvironmentsRuleParameters{ RequiredDeploymentEnvironments: []string{"test"}, diff --git a/github/repos_rules.go b/github/repos_rules.go index a25d03b3269..c859f7e4b0c 100644 --- a/github/repos_rules.go +++ b/github/repos_rules.go @@ -110,13 +110,6 @@ type RequiredWorkflowsRuleParameters struct { RequiredWorkflows []*RuleRequiredWorkflow `json:"workflows"` } -type RuleMergeQueue struct { -} - -// RequiredWorkflowsRuleParameters represents the workflows rule parameters. -type MergeQueueRuleParameters struct { -} - // RepositoryRule represents a GitHub Rule. type RepositoryRule struct { Type string `json:"type"` @@ -141,7 +134,7 @@ func (r *RepositoryRule) UnmarshalJSON(data []byte) error { r.Type = RepositoryRule.Type switch RepositoryRule.Type { - case "creation", "deletion", "required_linear_history", "required_signatures", "non_fast_forward": + case "creation", "deletion", "required_linear_history", "required_signatures", "non_fast_forward", "merge_queue": r.Parameters = nil case "update": if RepositoryRule.Parameters == nil { @@ -208,16 +201,7 @@ func (r *RepositoryRule) UnmarshalJSON(data []byte) error { rawParams := json.RawMessage(bytes) r.Parameters = &rawParams - case "merge_queue": - params := MergeQueueRuleParameters{} - if err := json.Unmarshal(*RepositoryRule.Parameters, ¶ms); err != nil { - return err - } - bytes, _ := json.Marshal(params) - rawParams := json.RawMessage(bytes) - - r.Parameters = &rawParams default: r.Type = "" r.Parameters = nil @@ -228,14 +212,9 @@ func (r *RepositoryRule) UnmarshalJSON(data []byte) error { } // NewMergeQueueRule creates a rule to only allow users with bypass permission to create matching refs. -func NewMergeQueueRule(params *RequiredStatusChecksRuleParameters) (rule *RepositoryRule) { - bytes, _ := json.Marshal(params) - - rawParams := json.RawMessage(bytes) - +func NewMergeQueueRule() (rule *RepositoryRule) { return &RepositoryRule{ - Type: "merge_queue", - Parameters: &rawParams, + Type: "merge_queue", } } diff --git a/github/repos_rules_test.go b/github/repos_rules_test.go index cbc3e5ce617..23ffd3ed5c1 100644 --- a/github/repos_rules_test.go +++ b/github/repos_rules_test.go @@ -67,6 +67,13 @@ func TestRepositoryRule_UnmarshalJSON(t *testing.T) { Parameters: nil, }, }, + "Valid merge_queue": { + data: `{"type":"merge_queue"}`, + want: &RepositoryRule{ + Type: "merge_queue", + Parameters: nil, + }, + }, "Valid non_fast_forward": { data: `{"type":"non_fast_forward"}`, want: &RepositoryRule{ From ae78db8a66f048df51a7a995b8a9cfeeea33429c Mon Sep 17 00:00:00 2001 From: Matthew Reidy Date: Thu, 18 Apr 2024 11:00:41 -0700 Subject: [PATCH 03/15] alphabetized items in repo_rules.go and AUTHORS, removed blank space in repo_rules.go --- AUTHORS | 4 ++-- github/repos_rules.go | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/AUTHORS b/AUTHORS index 01f3f6a3d12..0197b94a23a 100644 --- a/AUTHORS +++ b/AUTHORS @@ -303,6 +303,7 @@ Matt Gaunt Matt Landis Matt Moore Matt Simons +Matthew Reidy Maxime Bury Michael Meng Michael Spiegel @@ -484,5 +485,4 @@ Zach Latta zhouhaibing089 六开箱 缘生 -蒋航 -Matthew Reidy \ No newline at end of file +蒋航 \ No newline at end of file diff --git a/github/repos_rules.go b/github/repos_rules.go index c859f7e4b0c..87960822c37 100644 --- a/github/repos_rules.go +++ b/github/repos_rules.go @@ -134,7 +134,7 @@ func (r *RepositoryRule) UnmarshalJSON(data []byte) error { r.Type = RepositoryRule.Type switch RepositoryRule.Type { - case "creation", "deletion", "required_linear_history", "required_signatures", "non_fast_forward", "merge_queue": + case "creation", "deletion", "merge_queue", "non_fast_forward", "required_linear_history", "required_signatures": r.Parameters = nil case "update": if RepositoryRule.Parameters == nil { @@ -201,7 +201,6 @@ func (r *RepositoryRule) UnmarshalJSON(data []byte) error { rawParams := json.RawMessage(bytes) r.Parameters = &rawParams - default: r.Type = "" r.Parameters = nil From db987433b08576c58c74bead7ef38055ee39bdf4 Mon Sep 17 00:00:00 2001 From: Matthew William Reidy <48036844+Matthew-Reidy@users.noreply.github.com> Date: Thu, 18 Apr 2024 17:15:57 -0700 Subject: [PATCH 04/15] Update github/repos_rules.go Co-authored-by: Daniel Liao <10663736+liaodaniel@users.noreply.github.com> --- github/repos_rules.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/repos_rules.go b/github/repos_rules.go index 87960822c37..6f046a356a6 100644 --- a/github/repos_rules.go +++ b/github/repos_rules.go @@ -210,7 +210,7 @@ func (r *RepositoryRule) UnmarshalJSON(data []byte) error { return nil } -// NewMergeQueueRule creates a rule to only allow users with bypass permission to create matching refs. +// NewMergeQueueRule creates a rule to only allow merges via a merge queue. func NewMergeQueueRule() (rule *RepositoryRule) { return &RepositoryRule{ Type: "merge_queue", From 2c8a998409c709558ebac5449aeb96892dbc5a6f Mon Sep 17 00:00:00 2001 From: Matthew Reidy Date: Fri, 26 Apr 2024 09:57:37 -0700 Subject: [PATCH 05/15] issue3106 changes --- github/apps.go | 36 +++++++++++++++++ github/apps_test.go | 71 +++++++++++++++++++++++++++++++++ github/github-accessors.go | 8 ++++ github/github-accessors_test.go | 7 ++++ 4 files changed, 122 insertions(+) diff --git a/github/apps.go b/github/apps.go index 2ebfee505cd..6a2550f472d 100644 --- a/github/apps.go +++ b/github/apps.go @@ -56,6 +56,20 @@ type InstallationTokenOptions struct { Permissions *InstallationPermissions `json:"permissions,omitempty"` } +type InstallationTokenListRepoOptions struct { + // The IDs of the repositories that the installation token can access. + // Providing repository IDs restricts the access of an installation token to specific repositories. + RepositoryIDs []int64 `json:"repository_ids"` + + // The names of the repositories that the installation token can access. + // Providing repository names restricts the access of an installation token to specific repositories. + Repositories []string `json:"repositories,omitempty"` + + // The permissions granted to the access token. + // The permissions object includes the permission names and their access type. + Permissions *InstallationPermissions `json:"permissions,omitempty"` +} + // InstallationPermissions lists the repository and organization permissions for an installation. // // Permission names taken from: @@ -344,6 +358,28 @@ func (s *AppsService) CreateInstallationToken(ctx context.Context, id int64, opt return t, resp, nil } +// CreateInstallationTokenListRepos creates a new installation token with an empty repository list as a parameter. +// +// GitHub API docs: https://docs.github.com/rest/apps/apps#create-an-installation-access-token-for-an-app +// +//meta:operation POST /app/installations/{installation_id}/access_tokens +func (s *AppsService) CreateInstallationTokenListRepos(ctx context.Context, id int64, opts *InstallationTokenListRepoOptions) (*InstallationToken, *Response, error) { + u := fmt.Sprintf("app/installations/%v/access_tokens", id) + + req, err := s.client.NewRequest("POST", u, opts) + if err != nil { + return nil, nil, err + } + + t := new(InstallationToken) + resp, err := s.client.Do(ctx, req, t) + if err != nil { + return nil, resp, err + } + + return t, resp, nil +} + // CreateAttachment creates a new attachment on user comment containing a url. // // GitHub API docs: https://docs.github.com/enterprise-server@3.3/rest/reference/apps#create-a-content-attachment diff --git a/github/apps_test.go b/github/apps_test.go index a58326ea5ee..ea670344595 100644 --- a/github/apps_test.go +++ b/github/apps_test.go @@ -469,6 +469,77 @@ func TestAppsService_CreateInstallationTokenWithOptions(t *testing.T) { } } +func TestAppsService_CreateInstallationTokenListReposWithOptions(t *testing.T) { + client, mux, _, teardown := setup() + defer teardown() + + installationTokenListRepoOptions := &InstallationTokenListRepoOptions{ + Repositories: []string{"foo"}, + Permissions: &InstallationPermissions{ + Contents: String("write"), + Issues: String("read"), + }, + } + + mux.HandleFunc("/app/installations/1/access_tokens", func(w http.ResponseWriter, r *http.Request) { + v := new(InstallationTokenListRepoOptions) + assertNilError(t, json.NewDecoder(r.Body).Decode(v)) + + if !cmp.Equal(v, installationTokenListRepoOptions) { + t.Errorf("request sent %+v, want %+v", v, installationTokenListRepoOptions) + } + + testMethod(t, r, "POST") + fmt.Fprint(w, `{"token":"t"}`) + }) + + ctx := context.Background() + token, _, err := client.Apps.CreateInstallationTokenListRepos(ctx, 1, installationTokenListRepoOptions) + if err != nil { + t.Errorf("Apps.CreateInstallationTokenListRepos returned error: %v", err) + } + + want := &InstallationToken{Token: String("t")} + if !cmp.Equal(token, want) { + t.Errorf("Apps.CreateInstallationTokenListRepos returned %+v, want %+v", token, want) + } +} + +func TestAppsService_CreateInstallationTokenListReposWithNoOptions(t *testing.T) { + client, mux, _, teardown := setup() + defer teardown() + + mux.HandleFunc("/app/installations/1/access_tokens", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "POST") + fmt.Fprint(w, `{"token":"t"}`) + }) + + ctx := context.Background() + token, _, err := client.Apps.CreateInstallationTokenListRepos(ctx, 1, nil) + if err != nil { + t.Errorf("Apps.CreateInstallationTokenListRepos returned error: %v", err) + } + + want := &InstallationToken{Token: String("t")} + if !cmp.Equal(token, want) { + t.Errorf("Apps.CreateInstallationTokenListRepos returned %+v, want %+v", token, want) + } + + const methodName = "CreateInstallationTokenListRepos" + testBadOptions(t, methodName, func() (err error) { + _, _, err = client.Apps.CreateInstallationTokenListRepos(ctx, -1, nil) + return err + }) + + testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { + got, resp, err := client.Apps.CreateInstallationTokenListRepos(ctx, 1, nil) + if got != nil { + t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) + } + return resp, err + }) +} + func TestAppsService_CreateAttachement(t *testing.T) { client, mux, _, teardown := setup() defer teardown() diff --git a/github/github-accessors.go b/github/github-accessors.go index 13bf7d6668c..390ae086d3d 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -9062,6 +9062,14 @@ func (i *InstallationToken) GetToken() string { return *i.Token } +// GetPermissions returns the Permissions field. +func (i *InstallationTokenListRepoOptions) GetPermissions() *InstallationPermissions { + if i == nil { + return nil + } + return i.Permissions +} + // GetPermissions returns the Permissions field. func (i *InstallationTokenOptions) GetPermissions() *InstallationPermissions { if i == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 313e92c0596..8fafe9a2187 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -10608,6 +10608,13 @@ func TestInstallationToken_GetToken(tt *testing.T) { i.GetToken() } +func TestInstallationTokenListRepoOptions_GetPermissions(tt *testing.T) { + i := &InstallationTokenListRepoOptions{} + i.GetPermissions() + i = nil + i.GetPermissions() +} + func TestInstallationTokenOptions_GetPermissions(tt *testing.T) { i := &InstallationTokenOptions{} i.GetPermissions() From 13c74db21aaa119115e46735a6bce931f0ce7b56 Mon Sep 17 00:00:00 2001 From: Matthew Reidy Date: Mon, 29 Apr 2024 10:25:21 -0700 Subject: [PATCH 06/15] added more detail to function comment --- github/apps.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/github/apps.go b/github/apps.go index 6a2550f472d..21307ad0fb3 100644 --- a/github/apps.go +++ b/github/apps.go @@ -358,7 +358,9 @@ func (s *AppsService) CreateInstallationToken(ctx context.Context, id int64, opt return t, resp, nil } -// CreateInstallationTokenListRepos creates a new installation token with an empty repository list as a parameter. +// CreateInstallationTokenListRepos creates a new installation token with a list of all repositories in an installation which is not possible with CreateInstallationToken. +// +// differs from CreateInstallationToken by taking InstallationTokenListRepoOptions as a parameter which does not omit RepositoryIDs if that field is nil or an empty array. // // GitHub API docs: https://docs.github.com/rest/apps/apps#create-an-installation-access-token-for-an-app // From 6f4c7c1e4b004568be67f5c4ac91b0c06b514ef0 Mon Sep 17 00:00:00 2001 From: Matthew Reidy Date: Mon, 29 Apr 2024 11:38:38 -0700 Subject: [PATCH 07/15] small gramatical change --- github/apps.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/apps.go b/github/apps.go index 21307ad0fb3..6969daba6c0 100644 --- a/github/apps.go +++ b/github/apps.go @@ -360,7 +360,7 @@ func (s *AppsService) CreateInstallationToken(ctx context.Context, id int64, opt // CreateInstallationTokenListRepos creates a new installation token with a list of all repositories in an installation which is not possible with CreateInstallationToken. // -// differs from CreateInstallationToken by taking InstallationTokenListRepoOptions as a parameter which does not omit RepositoryIDs if that field is nil or an empty array. +// It differs from CreateInstallationToken by taking InstallationTokenListRepoOptions as a parameter which does not omit RepositoryIDs if that field is nil or an empty array. // // GitHub API docs: https://docs.github.com/rest/apps/apps#create-an-installation-access-token-for-an-app // From 133421cc334e315f6c7ed59dedcb90ffb2a3439c Mon Sep 17 00:00:00 2001 From: Matthew Reidy Date: Wed, 22 May 2024 11:31:59 -0700 Subject: [PATCH 08/15] added extra endpoint for issue 3137 --- github/github-accessors.go | 48 +++++++++++++++++++++++++++++ github/github-accessors_test.go | 54 +++++++++++++++++++++++++++++++++ github/repos_rules.go | 42 +++++++++++++++++++++++++ github/repos_rules_test.go | 46 ++++++++++++++++++++++++++++ 4 files changed, 190 insertions(+) diff --git a/github/github-accessors.go b/github/github-accessors.go index 0da23493ec2..92ff1084d19 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -20870,6 +20870,54 @@ func (r *RulesetLinks) GetSelf() *RulesetLink { return r.Self } +// GetConditions returns the Conditions field. +func (r *RulesetNoBPActr) GetConditions() *RulesetConditions { + if r == nil { + return nil + } + return r.Conditions +} + +// GetID returns the ID field if it's non-nil, zero value otherwise. +func (r *RulesetNoBPActr) GetID() int64 { + if r == nil || r.ID == nil { + return 0 + } + return *r.ID +} + +// GetLinks returns the Links field. +func (r *RulesetNoBPActr) GetLinks() *RulesetLinks { + if r == nil { + return nil + } + return r.Links +} + +// GetNodeID returns the NodeID field if it's non-nil, zero value otherwise. +func (r *RulesetNoBPActr) GetNodeID() string { + if r == nil || r.NodeID == nil { + return "" + } + return *r.NodeID +} + +// GetSourceType returns the SourceType field if it's non-nil, zero value otherwise. +func (r *RulesetNoBPActr) GetSourceType() string { + if r == nil || r.SourceType == nil { + return "" + } + return *r.SourceType +} + +// GetTarget returns the Target field if it's non-nil, zero value otherwise. +func (r *RulesetNoBPActr) GetTarget() string { + if r == nil || r.Target == nil { + return "" + } + return *r.Target +} + // GetProtected returns the Protected field if it's non-nil, zero value otherwise. func (r *RulesetRepositoryNamesConditionParameters) GetProtected() bool { if r == nil || r.Protected == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 8bb86540d9b..41458ceeb58 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -24249,6 +24249,60 @@ func TestRulesetLinks_GetSelf(tt *testing.T) { r.GetSelf() } +func TestRulesetNoBPActr_GetConditions(tt *testing.T) { + r := &RulesetNoBPActr{} + r.GetConditions() + r = nil + r.GetConditions() +} + +func TestRulesetNoBPActr_GetID(tt *testing.T) { + var zeroValue int64 + r := &RulesetNoBPActr{ID: &zeroValue} + r.GetID() + r = &RulesetNoBPActr{} + r.GetID() + r = nil + r.GetID() +} + +func TestRulesetNoBPActr_GetLinks(tt *testing.T) { + r := &RulesetNoBPActr{} + r.GetLinks() + r = nil + r.GetLinks() +} + +func TestRulesetNoBPActr_GetNodeID(tt *testing.T) { + var zeroValue string + r := &RulesetNoBPActr{NodeID: &zeroValue} + r.GetNodeID() + r = &RulesetNoBPActr{} + r.GetNodeID() + r = nil + r.GetNodeID() +} + +func TestRulesetNoBPActr_GetSourceType(tt *testing.T) { + var zeroValue string + r := &RulesetNoBPActr{SourceType: &zeroValue} + r.GetSourceType() + r = &RulesetNoBPActr{} + r.GetSourceType() + r = nil + r.GetSourceType() +} + +func TestRulesetNoBPActr_GetTarget(tt *testing.T) { + var zeroValue string + r := &RulesetNoBPActr{Target: &zeroValue} + r.GetTarget() + r = &RulesetNoBPActr{} + r.GetTarget() + r = nil + r.GetTarget() +} + func TestRulesetRepositoryNamesConditionParameters_GetProtected(tt *testing.T) { var zeroValue bool r := &RulesetRepositoryNamesConditionParameters{Protected: &zeroValue} diff --git a/github/repos_rules.go b/github/repos_rules.go index 6f046a356a6..77cb6a4bc19 100644 --- a/github/repos_rules.go +++ b/github/repos_rules.go @@ -395,6 +395,24 @@ type Ruleset struct { Rules []*RepositoryRule `json:"rules,omitempty"` } +// RulesetNoBPActr represents a GitHub ruleset object. does not omit BypassActors. +type RulesetNoBPActr struct { + ID *int64 `json:"id,omitempty"` + Name string `json:"name"` + // Possible values for Target are branch, tag + Target *string `json:"target,omitempty"` + // Possible values for SourceType are: Repository, Organization + SourceType *string `json:"source_type,omitempty"` + Source string `json:"source"` + // Possible values for Enforcement are: disabled, active, evaluate + Enforcement string `json:"enforcement"` + BypassActors []*BypassActor `json:"bypass_actors"` + NodeID *string `json:"node_id,omitempty"` + Links *RulesetLinks `json:"_links,omitempty"` + Conditions *RulesetConditions `json:"conditions,omitempty"` + Rules []*RepositoryRule `json:"rules,omitempty"` +} + // GetRulesForBranch gets all the rules that apply to the specified branch. // // GitHub API docs: https://docs.github.com/rest/repos/rules#get-rules-for-a-branch @@ -507,6 +525,30 @@ func (s *RepositoriesService) UpdateRuleset(ctx context.Context, owner, repo str return ruleset, resp, nil } +// UpdateRulesetNoBypassActr updates a ruleset for the specified repository. Accepts RulesetNoBPActr which does not omit ByPassActor +// +// this function is necessary as Ruleset struct does not marschall ByPassActor if passed as nil or an empty array +// +// GitHub API docs: https://docs.github.com/rest/repos/rules#update-a-repository-ruleset +// +//meta:operation PUT /repos/{owner}/{repo}/rulesets/{ruleset_id} +func (s *RepositoriesService) UpdateRulesetNoBypassActr(ctx context.Context, owner, repo string, rulesetID int64, rs *RulesetNoBPActr) (*RulesetNoBPActr, *Response, error) { + u := fmt.Sprintf("repos/%v/%v/rulesets/%v", owner, repo, rulesetID) + + req, err := s.client.NewRequest("PUT", u, rs) + if err != nil { + return nil, nil, err + } + + var ruleset *RulesetNoBPActr + resp, err := s.client.Do(ctx, req, &ruleset) + if err != nil { + return nil, resp, err + } + + return ruleset, resp, nil +} + // DeleteRuleset deletes a ruleset for the specified repository. // // GitHub API docs: https://docs.github.com/rest/repos/rules#delete-a-repository-ruleset diff --git a/github/repos_rules_test.go b/github/repos_rules_test.go index 23ffd3ed5c1..d8009eaed84 100644 --- a/github/repos_rules_test.go +++ b/github/repos_rules_test.go @@ -525,6 +525,52 @@ func TestRepositoriesService_GetRuleset(t *testing.T) { }) } +func TestRepositoriesService_UpdateRulesetNoBypassActr(t *testing.T) { + client, mux, _, teardown := setup() + defer teardown() + + mux.HandleFunc("/repos/o/repo/rulesets/42", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "PUT") + fmt.Fprint(w, `{ + "id": 42, + "name": "ruleset", + "source_type": "Repository", + "source": "o/repo", + "enforcement": "enabled" + }`) + }) + + ctx := context.Background() + ruleSet, _, err := client.Repositories.UpdateRulesetNoBypassActr(ctx, "o", "repo", 42, &RulesetNoBPActr{ + Name: "ruleset", + Enforcement: "enabled", + }) + if err != nil { + t.Errorf("Repositories.UpdateRulesetNoBypassActr returned error: %v", err) + } + + want := &RulesetNoBPActr{ + ID: Int64(42), + Name: "ruleset", + SourceType: String("Repository"), + Source: "o/repo", + Enforcement: "enabled", + } + if !cmp.Equal(ruleSet, want) { + t.Errorf("Repositories.UpdateRulesetNoBypassActr returned %+v, want %+v", ruleSet, want) + } + + const methodName = "UpdateRulesetNoBypassActr" + + testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { + got, resp, err := client.Repositories.UpdateRulesetNoBypassActr(ctx, "o", "repo", 42, nil) + if got != nil { + t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) + } + return resp, err + }) +} + func TestRepositoriesService_UpdateRuleset(t *testing.T) { client, mux, _, teardown := setup() defer teardown() From 33bfd28636a95f57c22155f214450d1054062551 Mon Sep 17 00:00:00 2001 From: Matthew Reidy Date: Thu, 30 May 2024 12:24:23 -0700 Subject: [PATCH 09/15] changed func param back to Ruleset --- github/github-accessors.go | 12 +++++------ github/github-accessors_test.go | 32 +++++++++++++-------------- github/repos_rules.go | 38 +++++++++++++++++++++++++-------- github/repos_rules_test.go | 27 ++++++++++++++--------- 4 files changed, 68 insertions(+), 41 deletions(-) diff --git a/github/github-accessors.go b/github/github-accessors.go index 92ff1084d19..a5bda844f04 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -20871,7 +20871,7 @@ func (r *RulesetLinks) GetSelf() *RulesetLink { } // GetConditions returns the Conditions field. -func (r *RulesetNoBPActr) GetConditions() *RulesetConditions { +func (r *RulesetNoOmitBypassActors) GetConditions() *RulesetConditions { if r == nil { return nil } @@ -20879,7 +20879,7 @@ func (r *RulesetNoBPActr) GetConditions() *RulesetConditions { } // GetID returns the ID field if it's non-nil, zero value otherwise. -func (r *RulesetNoBPActr) GetID() int64 { +func (r *RulesetNoOmitBypassActors) GetID() int64 { if r == nil || r.ID == nil { return 0 } @@ -20887,7 +20887,7 @@ func (r *RulesetNoBPActr) GetID() int64 { } // GetLinks returns the Links field. -func (r *RulesetNoBPActr) GetLinks() *RulesetLinks { +func (r *RulesetNoOmitBypassActors) GetLinks() *RulesetLinks { if r == nil { return nil } @@ -20895,7 +20895,7 @@ func (r *RulesetNoBPActr) GetLinks() *RulesetLinks { } // GetNodeID returns the NodeID field if it's non-nil, zero value otherwise. -func (r *RulesetNoBPActr) GetNodeID() string { +func (r *RulesetNoOmitBypassActors) GetNodeID() string { if r == nil || r.NodeID == nil { return "" } @@ -20903,7 +20903,7 @@ func (r *RulesetNoBPActr) GetNodeID() string { } // GetSourceType returns the SourceType field if it's non-nil, zero value otherwise. -func (r *RulesetNoBPActr) GetSourceType() string { +func (r *RulesetNoOmitBypassActors) GetSourceType() string { if r == nil || r.SourceType == nil { return "" } @@ -20911,7 +20911,7 @@ func (r *RulesetNoBPActr) GetSourceType() string { } // GetTarget returns the Target field if it's non-nil, zero value otherwise. -func (r *RulesetNoBPActr) GetTarget() string { +func (r *RulesetNoOmitBypassActors) GetTarget() string { if r == nil || r.Target == nil { return "" } diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 41458ceeb58..8a5fad6d35b 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -24249,55 +24249,55 @@ func TestRulesetLinks_GetSelf(tt *testing.T) { r.GetSelf() } -func TestRulesetNoBPActr_GetConditions(tt *testing.T) { - r := &RulesetNoBPActr{} +func TestRulesetNoOmitBypassActors_GetConditions(tt *testing.T) { + r := &RulesetNoOmitBypassActors{} r.GetConditions() r = nil r.GetConditions() } -func TestRulesetNoBPActr_GetID(tt *testing.T) { +func TestRulesetNoOmitBypassActors_GetID(tt *testing.T) { var zeroValue int64 - r := &RulesetNoBPActr{ID: &zeroValue} + r := &RulesetNoOmitBypassActors{ID: &zeroValue} r.GetID() - r = &RulesetNoBPActr{} + r = &RulesetNoOmitBypassActors{} r.GetID() r = nil r.GetID() } -func TestRulesetNoBPActr_GetLinks(tt *testing.T) { - r := &RulesetNoBPActr{} +func TestRulesetNoOmitBypassActors_GetLinks(tt *testing.T) { + r := &RulesetNoOmitBypassActors{} r.GetLinks() r = nil r.GetLinks() } -func TestRulesetNoBPActr_GetNodeID(tt *testing.T) { +func TestRulesetNoOmitBypassActors_GetNodeID(tt *testing.T) { var zeroValue string - r := &RulesetNoBPActr{NodeID: &zeroValue} + r := &RulesetNoOmitBypassActors{NodeID: &zeroValue} r.GetNodeID() - r = &RulesetNoBPActr{} + r = &RulesetNoOmitBypassActors{} r.GetNodeID() r = nil r.GetNodeID() } -func TestRulesetNoBPActr_GetSourceType(tt *testing.T) { +func TestRulesetNoOmitBypassActors_GetSourceType(tt *testing.T) { var zeroValue string - r := &RulesetNoBPActr{SourceType: &zeroValue} + r := &RulesetNoOmitBypassActors{SourceType: &zeroValue} r.GetSourceType() - r = &RulesetNoBPActr{} + r = &RulesetNoOmitBypassActors{} r.GetSourceType() r = nil r.GetSourceType() } -func TestRulesetNoBPActr_GetTarget(tt *testing.T) { +func TestRulesetNoOmitBypassActors_GetTarget(tt *testing.T) { var zeroValue string - r := &RulesetNoBPActr{Target: &zeroValue} + r := &RulesetNoOmitBypassActors{Target: &zeroValue} r.GetTarget() - r = &RulesetNoBPActr{} + r = &RulesetNoOmitBypassActors{} r.GetTarget() r = nil r.GetTarget() diff --git a/github/repos_rules.go b/github/repos_rules.go index 77cb6a4bc19..64b7075806a 100644 --- a/github/repos_rules.go +++ b/github/repos_rules.go @@ -395,8 +395,8 @@ type Ruleset struct { Rules []*RepositoryRule `json:"rules,omitempty"` } -// RulesetNoBPActr represents a GitHub ruleset object. does not omit BypassActors. -type RulesetNoBPActr struct { +// RulesetNoOmitBypassActors represents a GitHub ruleset object. The struct does not omit bypassActors if the field is nil or an empty array is passed. +type RulesetNoOmitBypassActors struct { ID *int64 `json:"id,omitempty"` Name string `json:"name"` // Possible values for Target are branch, tag @@ -525,28 +525,48 @@ func (s *RepositoriesService) UpdateRuleset(ctx context.Context, owner, repo str return ruleset, resp, nil } -// UpdateRulesetNoBypassActr updates a ruleset for the specified repository. Accepts RulesetNoBPActr which does not omit ByPassActor +// UpdateRulesetNoBypassActor updates a ruleset for the specified repository. // -// this function is necessary as Ruleset struct does not marschall ByPassActor if passed as nil or an empty array +// This function is necessary as the UpdateRuleset function does not marschall ByPassActor if passed as nil or an empty array. // // GitHub API docs: https://docs.github.com/rest/repos/rules#update-a-repository-ruleset // //meta:operation PUT /repos/{owner}/{repo}/rulesets/{ruleset_id} -func (s *RepositoriesService) UpdateRulesetNoBypassActr(ctx context.Context, owner, repo string, rulesetID int64, rs *RulesetNoBPActr) (*RulesetNoBPActr, *Response, error) { +func (s *RepositoriesService) UpdateRulesetNoBypassActor(ctx context.Context, owner, repo string, rulesetID int64, rs *Ruleset) (*Ruleset, *Response, error) { u := fmt.Sprintf("repos/%v/%v/rulesets/%v", owner, repo, rulesetID) - req, err := s.client.NewRequest("PUT", u, rs) + var rsNoBypassActor *RulesetNoOmitBypassActors + + if rs != nil { + rsNoBypassActor = &RulesetNoOmitBypassActors{ + ID: rs.ID, + Name: rs.Name, + Target: rs.Target, + SourceType: rs.SourceType, + Source: rs.Source, + Enforcement: rs.Enforcement, + BypassActors: rs.BypassActors, + NodeID: rs.NodeID, + Links: rs.Links, + Conditions: rs.Conditions, + Rules: rs.Rules, + } + } else { + rsNoBypassActor = &RulesetNoOmitBypassActors{} + } + + req, err := s.client.NewRequest("PUT", u, rsNoBypassActor) if err != nil { return nil, nil, err } - var ruleset *RulesetNoBPActr - resp, err := s.client.Do(ctx, req, &ruleset) + var ruleSet *Ruleset + resp, err := s.client.Do(ctx, req, &ruleSet) if err != nil { return nil, resp, err } - return ruleset, resp, nil + return ruleSet, resp, nil } // DeleteRuleset deletes a ruleset for the specified repository. diff --git a/github/repos_rules_test.go b/github/repos_rules_test.go index d8009eaed84..065d3385a3b 100644 --- a/github/repos_rules_test.go +++ b/github/repos_rules_test.go @@ -525,10 +525,16 @@ func TestRepositoriesService_GetRuleset(t *testing.T) { }) } -func TestRepositoriesService_UpdateRulesetNoBypassActr(t *testing.T) { +func TestRepositoriesService_UpdateRulesetNoBypassActor(t *testing.T) { client, mux, _, teardown := setup() defer teardown() + rs := &Ruleset{ + Name: "ruleset", + Source: "o/repo", + Enforcement: "enabled", + } + mux.HandleFunc("/repos/o/repo/rulesets/42", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") fmt.Fprint(w, `{ @@ -541,29 +547,29 @@ func TestRepositoriesService_UpdateRulesetNoBypassActr(t *testing.T) { }) ctx := context.Background() - ruleSet, _, err := client.Repositories.UpdateRulesetNoBypassActr(ctx, "o", "repo", 42, &RulesetNoBPActr{ - Name: "ruleset", - Enforcement: "enabled", - }) + + ruleSet, _, err := client.Repositories.UpdateRulesetNoBypassActor(ctx, "o", "repo", 42, rs) + if err != nil { - t.Errorf("Repositories.UpdateRulesetNoBypassActr returned error: %v", err) + t.Errorf("Repositories.UpdateRulesetNoBypassActor returned error: %v \n", err) } - want := &RulesetNoBPActr{ + want := &Ruleset{ ID: Int64(42), Name: "ruleset", SourceType: String("Repository"), Source: "o/repo", Enforcement: "enabled", } + if !cmp.Equal(ruleSet, want) { - t.Errorf("Repositories.UpdateRulesetNoBypassActr returned %+v, want %+v", ruleSet, want) + t.Errorf("Repositories.UpdateRulesetNoBypassActor returned %+v, want %+v", ruleSet, want) } - const methodName = "UpdateRulesetNoBypassActr" + const methodName = "UpdateRulesetNoBypassActor" testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.Repositories.UpdateRulesetNoBypassActr(ctx, "o", "repo", 42, nil) + got, resp, err := client.Repositories.UpdateRulesetNoBypassActor(ctx, "o", "repo", 42, nil) if got != nil { t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) } @@ -602,6 +608,7 @@ func TestRepositoriesService_UpdateRuleset(t *testing.T) { Source: "o/repo", Enforcement: "enabled", } + if !cmp.Equal(ruleSet, want) { t.Errorf("Repositories.UpdateRuleset returned %+v, want %+v", ruleSet, want) } From 0feea609bcf6864835d5ccae79a48e29ed6f6356 Mon Sep 17 00:00:00 2001 From: Matthew William Reidy <48036844+Matthew-Reidy@users.noreply.github.com> Date: Thu, 30 May 2024 12:59:22 -0700 Subject: [PATCH 10/15] Update github/repos_rules.go Co-authored-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/repos_rules.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/github/repos_rules.go b/github/repos_rules.go index 64b7075806a..0a34ed62835 100644 --- a/github/repos_rules.go +++ b/github/repos_rules.go @@ -535,7 +535,7 @@ func (s *RepositoriesService) UpdateRuleset(ctx context.Context, owner, repo str func (s *RepositoriesService) UpdateRulesetNoBypassActor(ctx context.Context, owner, repo string, rulesetID int64, rs *Ruleset) (*Ruleset, *Response, error) { u := fmt.Sprintf("repos/%v/%v/rulesets/%v", owner, repo, rulesetID) - var rsNoBypassActor *RulesetNoOmitBypassActors + rsNoBypassActor := &RulesetNoOmitBypassActors{} if rs != nil { rsNoBypassActor = &RulesetNoOmitBypassActors{ @@ -551,8 +551,6 @@ func (s *RepositoriesService) UpdateRulesetNoBypassActor(ctx context.Context, ow Conditions: rs.Conditions, Rules: rs.Rules, } - } else { - rsNoBypassActor = &RulesetNoOmitBypassActors{} } req, err := s.client.NewRequest("PUT", u, rsNoBypassActor) From aef75384c970f21b21f3ceb97fd8223f443d4fa4 Mon Sep 17 00:00:00 2001 From: Matthew William Reidy <48036844+Matthew-Reidy@users.noreply.github.com> Date: Thu, 30 May 2024 12:59:28 -0700 Subject: [PATCH 11/15] Update github/repos_rules.go Co-authored-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/repos_rules.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/github/repos_rules.go b/github/repos_rules.go index 0a34ed62835..4db75a2ebc0 100644 --- a/github/repos_rules.go +++ b/github/repos_rules.go @@ -395,8 +395,8 @@ type Ruleset struct { Rules []*RepositoryRule `json:"rules,omitempty"` } -// RulesetNoOmitBypassActors represents a GitHub ruleset object. The struct does not omit bypassActors if the field is nil or an empty array is passed. -type RulesetNoOmitBypassActors struct { +// rulesetNoOmitBypassActors represents a GitHub ruleset object. The struct does not omit bypassActors if the field is nil or an empty array is passed. +type rulesetNoOmitBypassActors struct { ID *int64 `json:"id,omitempty"` Name string `json:"name"` // Possible values for Target are branch, tag From e34b7b3b6a3d2f27129c15471ddd4d1b29f0cc31 Mon Sep 17 00:00:00 2001 From: Matthew William Reidy <48036844+Matthew-Reidy@users.noreply.github.com> Date: Thu, 30 May 2024 13:29:37 -0700 Subject: [PATCH 12/15] Update github/repos_rules.go Co-authored-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/repos_rules.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/repos_rules.go b/github/repos_rules.go index 4db75a2ebc0..1e491e7d0f1 100644 --- a/github/repos_rules.go +++ b/github/repos_rules.go @@ -535,7 +535,7 @@ func (s *RepositoriesService) UpdateRuleset(ctx context.Context, owner, repo str func (s *RepositoriesService) UpdateRulesetNoBypassActor(ctx context.Context, owner, repo string, rulesetID int64, rs *Ruleset) (*Ruleset, *Response, error) { u := fmt.Sprintf("repos/%v/%v/rulesets/%v", owner, repo, rulesetID) - rsNoBypassActor := &RulesetNoOmitBypassActors{} + rsNoBypassActor := &rulesetNoOmitBypassActors{} if rs != nil { rsNoBypassActor = &RulesetNoOmitBypassActors{ From 0fd05d7d3224d3a755d7afc1251c7de675771284 Mon Sep 17 00:00:00 2001 From: Matthew William Reidy <48036844+Matthew-Reidy@users.noreply.github.com> Date: Thu, 30 May 2024 13:29:42 -0700 Subject: [PATCH 13/15] Update github/repos_rules.go Co-authored-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/repos_rules.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/repos_rules.go b/github/repos_rules.go index 1e491e7d0f1..94c713986f3 100644 --- a/github/repos_rules.go +++ b/github/repos_rules.go @@ -538,7 +538,7 @@ func (s *RepositoriesService) UpdateRulesetNoBypassActor(ctx context.Context, ow rsNoBypassActor := &rulesetNoOmitBypassActors{} if rs != nil { - rsNoBypassActor = &RulesetNoOmitBypassActors{ + rsNoBypassActor = &rulesetNoOmitBypassActors{ ID: rs.ID, Name: rs.Name, Target: rs.Target, From 1f7c1eff61c38c7baffeb9fe3b0a6bbf7d4255b3 Mon Sep 17 00:00:00 2001 From: Matthew Reidy Date: Thu, 30 May 2024 13:38:50 -0700 Subject: [PATCH 14/15] changed struct to non-exported, code styling change in UpdateRulesetNoBypassActor, regenerated files --- github/github-accessors.go | 48 ----------------------------- github/github-accessors_test.go | 54 --------------------------------- 2 files changed, 102 deletions(-) diff --git a/github/github-accessors.go b/github/github-accessors.go index 1249cb8abab..421922d33db 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -20870,54 +20870,6 @@ func (r *RulesetLinks) GetSelf() *RulesetLink { return r.Self } -// GetConditions returns the Conditions field. -func (r *RulesetNoOmitBypassActors) GetConditions() *RulesetConditions { - if r == nil { - return nil - } - return r.Conditions -} - -// GetID returns the ID field if it's non-nil, zero value otherwise. -func (r *RulesetNoOmitBypassActors) GetID() int64 { - if r == nil || r.ID == nil { - return 0 - } - return *r.ID -} - -// GetLinks returns the Links field. -func (r *RulesetNoOmitBypassActors) GetLinks() *RulesetLinks { - if r == nil { - return nil - } - return r.Links -} - -// GetNodeID returns the NodeID field if it's non-nil, zero value otherwise. -func (r *RulesetNoOmitBypassActors) GetNodeID() string { - if r == nil || r.NodeID == nil { - return "" - } - return *r.NodeID -} - -// GetSourceType returns the SourceType field if it's non-nil, zero value otherwise. -func (r *RulesetNoOmitBypassActors) GetSourceType() string { - if r == nil || r.SourceType == nil { - return "" - } - return *r.SourceType -} - -// GetTarget returns the Target field if it's non-nil, zero value otherwise. -func (r *RulesetNoOmitBypassActors) GetTarget() string { - if r == nil || r.Target == nil { - return "" - } - return *r.Target -} - // GetProtected returns the Protected field if it's non-nil, zero value otherwise. func (r *RulesetRepositoryNamesConditionParameters) GetProtected() bool { if r == nil || r.Protected == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 7ee794f4908..8753c42b79e 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -24249,60 +24249,6 @@ func TestRulesetLinks_GetSelf(tt *testing.T) { r.GetSelf() } -func TestRulesetNoOmitBypassActors_GetConditions(tt *testing.T) { - r := &RulesetNoOmitBypassActors{} - r.GetConditions() - r = nil - r.GetConditions() -} - -func TestRulesetNoOmitBypassActors_GetID(tt *testing.T) { - var zeroValue int64 - r := &RulesetNoOmitBypassActors{ID: &zeroValue} - r.GetID() - r = &RulesetNoOmitBypassActors{} - r.GetID() - r = nil - r.GetID() -} - -func TestRulesetNoOmitBypassActors_GetLinks(tt *testing.T) { - r := &RulesetNoOmitBypassActors{} - r.GetLinks() - r = nil - r.GetLinks() -} - -func TestRulesetNoOmitBypassActors_GetNodeID(tt *testing.T) { - var zeroValue string - r := &RulesetNoOmitBypassActors{NodeID: &zeroValue} - r.GetNodeID() - r = &RulesetNoOmitBypassActors{} - r.GetNodeID() - r = nil - r.GetNodeID() -} - -func TestRulesetNoOmitBypassActors_GetSourceType(tt *testing.T) { - var zeroValue string - r := &RulesetNoOmitBypassActors{SourceType: &zeroValue} - r.GetSourceType() - r = &RulesetNoOmitBypassActors{} - r.GetSourceType() - r = nil - r.GetSourceType() -} - -func TestRulesetNoOmitBypassActors_GetTarget(tt *testing.T) { - var zeroValue string - r := &RulesetNoOmitBypassActors{Target: &zeroValue} - r.GetTarget() - r = &RulesetNoOmitBypassActors{} - r.GetTarget() - r = nil - r.GetTarget() -} - func TestRulesetRepositoryNamesConditionParameters_GetProtected(tt *testing.T) { var zeroValue bool r := &RulesetRepositoryNamesConditionParameters{Protected: &zeroValue} From fa5bba3f0a2f0bd1d80231c986946d3740b93368 Mon Sep 17 00:00:00 2001 From: Matthew Reidy Date: Tue, 9 Jul 2024 09:45:07 -0700 Subject: [PATCH 15/15] fixed spelling nit --- github/repos_rules.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/repos_rules.go b/github/repos_rules.go index 94c713986f3..326e63ed5d3 100644 --- a/github/repos_rules.go +++ b/github/repos_rules.go @@ -527,7 +527,7 @@ func (s *RepositoriesService) UpdateRuleset(ctx context.Context, owner, repo str // UpdateRulesetNoBypassActor updates a ruleset for the specified repository. // -// This function is necessary as the UpdateRuleset function does not marschall ByPassActor if passed as nil or an empty array. +// This function is necessary as the UpdateRuleset function does not marshal ByPassActor if passed as nil or an empty array. // // GitHub API docs: https://docs.github.com/rest/repos/rules#update-a-repository-ruleset //