From 59da3f32d5aa7d716a19f1a7a218ef3873c006b2 Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Tue, 24 Jun 2025 10:41:46 -0400 Subject: [PATCH 01/26] Bump go-github from v72 to v73 in /scrape (#3600) --- scrape/apps.go | 2 +- scrape/apps_test.go | 2 +- scrape/go.mod | 2 +- scrape/go.sum | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scrape/apps.go b/scrape/apps.go index 1898076e23e..291a194efa4 100644 --- a/scrape/apps.go +++ b/scrape/apps.go @@ -18,7 +18,7 @@ import ( "strings" "github.com/PuerkitoBio/goquery" - "github.com/google/go-github/v72/github" + "github.com/google/go-github/v73/github" ) // AppRestrictionsEnabled returns whether the specified organization has diff --git a/scrape/apps_test.go b/scrape/apps_test.go index 89b345a9f22..e7f6da6dcd8 100644 --- a/scrape/apps_test.go +++ b/scrape/apps_test.go @@ -10,7 +10,7 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/google/go-github/v72/github" + "github.com/google/go-github/v73/github" ) func Test_AppRestrictionsEnabled(t *testing.T) { diff --git a/scrape/go.mod b/scrape/go.mod index 5eb5a830fad..c39f77a8034 100644 --- a/scrape/go.mod +++ b/scrape/go.mod @@ -5,7 +5,7 @@ go 1.23.0 require ( github.com/PuerkitoBio/goquery v1.10.3 github.com/google/go-cmp v0.7.0 - github.com/google/go-github/v72 v72.0.0 + github.com/google/go-github/v73 v73.0.0 github.com/xlzd/gotp v0.1.0 golang.org/x/net v0.41.0 ) diff --git a/scrape/go.sum b/scrape/go.sum index 8b12db5bc91..ae2e3715f0b 100644 --- a/scrape/go.sum +++ b/scrape/go.sum @@ -6,8 +6,8 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= -github.com/google/go-github/v72 v72.0.0 h1:FcIO37BLoVPBO9igQQ6tStsv2asG4IPcYFi655PPvBM= -github.com/google/go-github/v72 v72.0.0/go.mod h1:WWtw8GMRiL62mvIquf1kO3onRHeWWKmK01qdCY8c5fg= +github.com/google/go-github/v73 v73.0.0 h1:aR+Utnh+Y4mMkS+2qLQwcQ/cF9mOTpdwnzlaw//rG24= +github.com/google/go-github/v73 v73.0.0/go.mod h1:fa6w8+/V+edSU0muqdhCVY7Beh1M8F1IlQPZIANKIYw= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= github.com/xlzd/gotp v0.1.0 h1:37blvlKCh38s+fkem+fFh7sMnceltoIEBYTVXyoa5Po= From 49704bf0f76662f17db32fc3888279629d3d748c Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Wed, 25 Jun 2025 18:32:07 +0300 Subject: [PATCH 02/26] refactor: Simplify error handling in JSON decoding in tests (#3602) --- github/enterprise_actions_runners_test.go | 5 +---- github/orgs_codesecurity_configurations_test.go | 15 +++------------ 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/github/enterprise_actions_runners_test.go b/github/enterprise_actions_runners_test.go index b3a5770b6ad..dd714078f94 100644 --- a/github/enterprise_actions_runners_test.go +++ b/github/enterprise_actions_runners_test.go @@ -24,10 +24,7 @@ func TestEnterpriseService_GenerateEnterpriseJITConfig(t *testing.T) { mux.HandleFunc("/enterprises/o/actions/runners/generate-jitconfig", func(w http.ResponseWriter, r *http.Request) { v := new(GenerateJITConfigRequest) - err := json.NewDecoder(r.Body).Decode(v) - if err != nil { - t.Errorf("Request body decode failed: %v", err) - } + assertNilError(t, json.NewDecoder(r.Body).Decode(v)) testMethod(t, r, "POST") if !cmp.Equal(v, input) { diff --git a/github/orgs_codesecurity_configurations_test.go b/github/orgs_codesecurity_configurations_test.go index ef916efbffd..f2a35c2c3cd 100644 --- a/github/orgs_codesecurity_configurations_test.go +++ b/github/orgs_codesecurity_configurations_test.go @@ -111,10 +111,7 @@ func TestOrganizationsService_CreateCodeSecurityConfiguration(t *testing.T) { mux.HandleFunc("/orgs/o/code-security/configurations", func(w http.ResponseWriter, r *http.Request) { v := new(CodeSecurityConfiguration) - err := json.NewDecoder(r.Body).Decode(v) - if err != nil { - t.Errorf("Organizations.CreateCodeSecurityConfiguration request body decode failed: %v", err) - } + assertNilError(t, json.NewDecoder(r.Body).Decode(v)) if !reflect.DeepEqual(v, input) { t.Errorf("Organizations.CreateCodeSecurityConfiguration request body = %+v, want %+v", v, input) @@ -244,10 +241,7 @@ func TestOrganizationsService_UpdateCodeSecurityConfiguration(t *testing.T) { mux.HandleFunc("/orgs/o/code-security/configurations/1", func(w http.ResponseWriter, r *http.Request) { v := new(CodeSecurityConfiguration) - err := json.NewDecoder(r.Body).Decode(v) - if err != nil { - t.Errorf("Organizations.UpdateCodeSecurityConfiguration request body decode failed: %v", err) - } + assertNilError(t, json.NewDecoder(r.Body).Decode(v)) if !reflect.DeepEqual(v, input) { t.Errorf("Organizations.UpdateCodeSecurityConfiguration request body = %+v, want %+v", v, input) @@ -329,10 +323,7 @@ func TestOrganizationsService_AttachCodeSecurityConfigurationsToRepositories(t * SelectedRepositoryIDs []int64 `json:"selected_repository_ids,omitempty"` } v := new(request) - err := json.NewDecoder(r.Body).Decode(v) - if err != nil { - t.Errorf("Organizations.AttachCodeSecurityConfigurationsToRepositories request body decode failed: %v", err) - } + assertNilError(t, json.NewDecoder(r.Body).Decode(v)) if v.Scope != "selected" { t.Errorf("Organizations.AttachCodeSecurityConfigurationsToRepositories request body scope = %s, want selected", v.Scope) } From 94932781957d68c142dcf8aa4d6d9d1143ad2f80 Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Wed, 25 Jun 2025 18:44:09 +0300 Subject: [PATCH 03/26] refactor: fix revive.unused-parameter lint issues (#3603) --- .golangci.yml | 1 + github/actions_artifacts_test.go | 4 +- github/actions_cache_test.go | 4 +- github/actions_runner_groups_test.go | 14 +++--- github/actions_runners_test.go | 4 +- github/actions_secrets_test.go | 12 ++--- github/actions_variables_test.go | 12 ++--- github/actions_workflow_jobs_test.go | 2 +- github/actions_workflows_test.go | 12 ++--- github/activity_star_test.go | 4 +- github/admin_users_test.go | 4 +- github/authorizations_test.go | 4 +- github/codespaces_secrets_test.go | 18 ++++---- github/codespaces_test.go | 2 +- github/dependabot_secrets_test.go | 10 ++-- .../enterprise_actions_runner_groups_test.go | 14 +++--- github/enterprise_actions_runners_test.go | 2 +- ...erprise_code_security_and_analysis_test.go | 4 +- github/enterprise_manage_ghes_config_test.go | 2 +- .../enterprise_network_configurations_test.go | 2 +- github/enterprise_properties_test.go | 2 +- github/enterprise_rules_test.go | 2 +- github/gists_comments_test.go | 2 +- github/gists_test.go | 6 +-- github/git_commits_test.go | 2 +- github/git_refs_test.go | 2 +- github/github.go | 2 +- github/github_test.go | 46 +++++++++---------- github/interactions_orgs_test.go | 2 +- github/interactions_repos_test.go | 2 +- github/issues_assignees_test.go | 2 +- github/issues_comments_test.go | 2 +- github/issues_labels_test.go | 6 +-- github/issues_milestones_test.go | 2 +- github/messages_test.go | 2 +- github/migrations.go | 2 +- github/migrations_user.go | 2 +- github/orgs_hooks_test.go | 4 +- github/orgs_issue_types_test.go | 2 +- github/orgs_members_test.go | 6 +-- github/orgs_network_configurations_test.go | 2 +- github/orgs_outside_collaborators_test.go | 4 +- github/orgs_packages_test.go | 8 ++-- github/orgs_properties_test.go | 4 +- github/orgs_rules_test.go | 2 +- github/orgs_security_managers_test.go | 4 +- github/orgs_test.go | 2 +- github/pulls_comments_test.go | 2 +- github/pulls_reviewers_test.go | 4 +- github/pulls_test.go | 4 +- github/rate_limit_test.go | 2 +- github/repos_actions_access_test.go | 2 +- github/repos_comments_test.go | 2 +- github/repos_contents_test.go | 4 +- .../repos_deployment_branch_policies_test.go | 6 +-- github/repos_environments_test.go | 2 +- github/repos_hooks_test.go | 10 ++-- github/repos_keys_test.go | 2 +- github/repos_pages_test.go | 2 +- github/repos_prereceive_hooks_test.go | 2 +- github/repos_releases.go | 2 +- github/repos_releases_test.go | 4 +- github/repos_rules_test.go | 2 +- github/repos_test.go | 10 ++-- github/scim.go | 2 +- github/teams_discussion_comments_test.go | 2 +- github/teams_discussions_test.go | 4 +- github/teams_test.go | 4 +- github/users_emails_test.go | 2 +- github/users_followers_test.go | 4 +- github/users_gpg_keys_test.go | 2 +- github/users_keys_test.go | 2 +- github/users_packages_test.go | 16 +++---- github/users_ssh_signing_keys_test.go | 2 +- scrape/apps.go | 2 +- scrape/apps_test.go | 8 ++-- scrape/forms_test.go | 4 +- scrape/payment.go | 2 +- tools/sliceofpointers/sliceofpointers.go | 2 +- 79 files changed, 188 insertions(+), 187 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index baef17feda4..bf47cb3b643 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -98,6 +98,7 @@ linters: - name: unexported-naming - name: unexported-return - name: unreachable-code + - name: unused-parameter - name: use-any - name: var-declaration - name: var-naming diff --git a/github/actions_artifacts_test.go b/github/actions_artifacts_test.go index 6becfcf79d5..efb84011f5d 100644 --- a/github/actions_artifacts_test.go +++ b/github/actions_artifacts_test.go @@ -320,7 +320,7 @@ func TestActionsService_DownloadArtifact(t *testing.T) { }) // Add custom round tripper - client.client.Transport = roundTripperFunc(func(r *http.Request) (*http.Response, error) { + client.client.Transport = roundTripperFunc(func(*http.Request) (*http.Response, error) { return nil, errors.New("failed to download artifact") }) // propagate custom round tripper to client without CheckRedirect @@ -529,7 +529,7 @@ func TestActionsService_DeleteArtifact(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repos/o/r/actions/artifacts/1", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/actions/artifacts/1", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) diff --git a/github/actions_cache_test.go b/github/actions_cache_test.go index 4831b612c4a..7cad1445425 100644 --- a/github/actions_cache_test.go +++ b/github/actions_cache_test.go @@ -100,7 +100,7 @@ func TestActionsService_DeleteCachesByKey(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repos/o/r/actions/caches", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/actions/caches", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") testFormValues(t, r, values{"key": "1", "ref": "main"}) }) @@ -162,7 +162,7 @@ func TestActionsService_DeleteCachesByID(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repos/o/r/actions/caches/1", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/actions/caches/1", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) diff --git a/github/actions_runner_groups_test.go b/github/actions_runner_groups_test.go index c7154b74e0a..c16836e7442 100644 --- a/github/actions_runner_groups_test.go +++ b/github/actions_runner_groups_test.go @@ -153,7 +153,7 @@ func TestActionsService_DeleteOrganizationRunnerGroup(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/orgs/o/actions/runner-groups/2", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o/actions/runner-groups/2", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) @@ -328,7 +328,7 @@ func TestActionsService_SetRepositoryAccessRunnerGroup(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/orgs/o/actions/runner-groups/2/repositories", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o/actions/runner-groups/2/repositories", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") }) @@ -360,7 +360,7 @@ func TestActionsService_AddRepositoryAccessRunnerGroup(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/orgs/o/actions/runner-groups/2/repositories/42", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o/actions/runner-groups/2/repositories/42", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") }) @@ -385,7 +385,7 @@ func TestActionsService_RemoveRepositoryAccessRunnerGroup(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/orgs/o/actions/runner-groups/2/repositories/42", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o/actions/runner-groups/2/repositories/42", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) @@ -453,7 +453,7 @@ func TestActionsService_SetRunnerGroupRunners(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/orgs/o/actions/runner-groups/2/runners", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o/actions/runner-groups/2/runners", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") }) @@ -485,7 +485,7 @@ func TestActionsService_AddRunnerGroupRunners(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/orgs/o/actions/runner-groups/2/runners/42", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o/actions/runner-groups/2/runners/42", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") }) @@ -510,7 +510,7 @@ func TestActionsService_RemoveRunnerGroupRunners(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/orgs/o/actions/runner-groups/2/runners/42", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o/actions/runner-groups/2/runners/42", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) diff --git a/github/actions_runners_test.go b/github/actions_runners_test.go index 4c174d3c878..48c3cdfff03 100644 --- a/github/actions_runners_test.go +++ b/github/actions_runners_test.go @@ -306,7 +306,7 @@ func TestActionsService_RemoveRunner(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repos/o/r/actions/runners/21", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/actions/runners/21", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) @@ -529,7 +529,7 @@ func TestActionsService_RemoveOrganizationRunner(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/orgs/o/actions/runners/21", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o/actions/runners/21", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) diff --git a/github/actions_secrets_test.go b/github/actions_secrets_test.go index ec23f3b52c3..64437260c3d 100644 --- a/github/actions_secrets_test.go +++ b/github/actions_secrets_test.go @@ -325,7 +325,7 @@ func TestActionsService_DeleteRepoSecret(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repos/o/r/actions/secrets/NAME", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/actions/secrets/NAME", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) @@ -546,7 +546,7 @@ func TestActionsService_SetSelectedReposForOrgSecret(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/orgs/o/actions/secrets/NAME/repositories", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o/actions/secrets/NAME/repositories", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") testHeader(t, r, "Content-Type", "application/json") testBody(t, r, `{"selected_repository_ids":[64780797]}`+"\n") @@ -573,7 +573,7 @@ func TestActionsService_AddSelectedRepoToOrgSecret(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/orgs/o/actions/secrets/NAME/repositories/1234", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o/actions/secrets/NAME/repositories/1234", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") }) @@ -599,7 +599,7 @@ func TestActionsService_RemoveSelectedRepoFromOrgSecret(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/orgs/o/actions/secrets/NAME/repositories/1234", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o/actions/secrets/NAME/repositories/1234", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) @@ -625,7 +625,7 @@ func TestActionsService_DeleteOrgSecret(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/orgs/o/actions/secrets/NAME", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o/actions/secrets/NAME", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) @@ -835,7 +835,7 @@ func TestActionsService_DeleteEnvSecret(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repositories/1/environments/e/secrets/secret", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repositories/1/environments/e/secrets/secret", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) diff --git a/github/actions_variables_test.go b/github/actions_variables_test.go index 5a1813ab73d..83c1b8cce64 100644 --- a/github/actions_variables_test.go +++ b/github/actions_variables_test.go @@ -209,7 +209,7 @@ func TestActionsService_DeleteRepoVariable(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repos/o/r/actions/variables/NAME", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/actions/variables/NAME", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) @@ -429,7 +429,7 @@ func TestActionsService_SetSelectedReposForOrgSVariable(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/orgs/o/actions/variables/NAME/repositories", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o/actions/variables/NAME/repositories", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") testHeader(t, r, "Content-Type", "application/json") testBody(t, r, `{"selected_repository_ids":[64780797]}`+"\n") @@ -456,7 +456,7 @@ func TestActionsService_AddSelectedRepoToOrgVariable(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/orgs/o/actions/variables/NAME/repositories/1234", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o/actions/variables/NAME/repositories/1234", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") }) @@ -482,7 +482,7 @@ func TestActionsService_RemoveSelectedRepoFromOrgVariable(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/orgs/o/actions/variables/NAME/repositories/1234", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o/actions/variables/NAME/repositories/1234", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) @@ -508,7 +508,7 @@ func TestActionsService_DeleteOrgVariable(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/orgs/o/actions/variables/NAME", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o/actions/variables/NAME", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) @@ -680,7 +680,7 @@ func TestActionsService_DeleteEnvVariable(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repos/usr/1/environments/e/variables/variable", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/usr/1/environments/e/variables/variable", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) diff --git a/github/actions_workflow_jobs_test.go b/github/actions_workflow_jobs_test.go index ccc8ae8bf91..85aaa2b6bbe 100644 --- a/github/actions_workflow_jobs_test.go +++ b/github/actions_workflow_jobs_test.go @@ -230,7 +230,7 @@ func TestActionsService_GetWorkflowJobLogs(t *testing.T) { }) // Add custom round tripper - client.client.Transport = roundTripperFunc(func(r *http.Request) (*http.Response, error) { + client.client.Transport = roundTripperFunc(func(*http.Request) (*http.Response, error) { return nil, errors.New("failed to get workflow logs") }) // propagate custom round tripper to client without CheckRedirect diff --git a/github/actions_workflows_test.go b/github/actions_workflows_test.go index 46e904b3747..fddf6b70c5f 100644 --- a/github/actions_workflows_test.go +++ b/github/actions_workflows_test.go @@ -241,7 +241,7 @@ func TestActionsService_CreateWorkflowDispatchEventByID(t *testing.T) { "key": "value", }, } - mux.HandleFunc("/repos/o/r/actions/workflows/72844/dispatches", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/actions/workflows/72844/dispatches", func(_ http.ResponseWriter, r *http.Request) { var v CreateWorkflowDispatchEventRequest assertNilError(t, json.NewDecoder(r.Body).Decode(&v)) @@ -285,7 +285,7 @@ func TestActionsService_CreateWorkflowDispatchEventByFileName(t *testing.T) { "key": "value", }, } - mux.HandleFunc("/repos/o/r/actions/workflows/main.yml/dispatches", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/actions/workflows/main.yml/dispatches", func(_ http.ResponseWriter, r *http.Request) { var v CreateWorkflowDispatchEventRequest assertNilError(t, json.NewDecoder(r.Body).Decode(&v)) @@ -323,7 +323,7 @@ func TestActionsService_EnableWorkflowByID(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repos/o/r/actions/workflows/72844/enable", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/actions/workflows/72844/enable", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") if r.Body != http.NoBody { t.Errorf("Request body = %+v, want %+v", r.Body, http.NoBody) @@ -358,7 +358,7 @@ func TestActionsService_EnableWorkflowByFilename(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repos/o/r/actions/workflows/main.yml/enable", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/actions/workflows/main.yml/enable", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") if r.Body != http.NoBody { t.Errorf("Request body = %+v, want %+v", r.Body, http.NoBody) @@ -393,7 +393,7 @@ func TestActionsService_DisableWorkflowByID(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repos/o/r/actions/workflows/72844/disable", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/actions/workflows/72844/disable", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") if r.Body != http.NoBody { t.Errorf("Request body = %+v, want %+v", r.Body, http.NoBody) @@ -428,7 +428,7 @@ func TestActionsService_DisableWorkflowByFileName(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repos/o/r/actions/workflows/main.yml/disable", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/actions/workflows/main.yml/disable", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") if r.Body != http.NoBody { t.Errorf("Request body = %+v, want %+v", r.Body, http.NoBody) diff --git a/github/activity_star_test.go b/github/activity_star_test.go index 57b3ef6521e..6a3d90ef5ea 100644 --- a/github/activity_star_test.go +++ b/github/activity_star_test.go @@ -222,7 +222,7 @@ func TestActivityService_Star(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/user/starred/o/r", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/user/starred/o/r", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") }) @@ -256,7 +256,7 @@ func TestActivityService_Unstar(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/user/starred/o/r", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/user/starred/o/r", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) diff --git a/github/admin_users_test.go b/github/admin_users_test.go index 4806c53461e..4140f0f8594 100644 --- a/github/admin_users_test.go +++ b/github/admin_users_test.go @@ -66,7 +66,7 @@ func TestAdminUsers_Delete(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/admin/users/github", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/admin/users/github", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) @@ -163,7 +163,7 @@ func TestUserImpersonation_Delete(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/admin/users/github/authorizations", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/admin/users/github/authorizations", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) diff --git a/github/authorizations_test.go b/github/authorizations_test.go index 1a0612a5080..5c9322a71db 100644 --- a/github/authorizations_test.go +++ b/github/authorizations_test.go @@ -120,7 +120,7 @@ func TestDeleteGrant(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/applications/id/grant", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/applications/id/grant", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") testBody(t, r, `{"access_token":"a"}`+"\n") testHeader(t, r, "Accept", mediaTypeOAuthAppPreview) @@ -183,7 +183,7 @@ func TestAuthorizationsService_DeleteImpersonation(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/admin/users/u/authorizations", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/admin/users/u/authorizations", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) diff --git a/github/codespaces_secrets_test.go b/github/codespaces_secrets_test.go index 2c8ae931b00..551cb1f6699 100644 --- a/github/codespaces_secrets_test.go +++ b/github/codespaces_secrets_test.go @@ -319,7 +319,7 @@ func TestCodespacesService_DeleteSecret(t *testing.T) { { name: "User", handleFunc: func(mux *http.ServeMux) { - mux.HandleFunc("/user/codespaces/secrets/NAME", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/user/codespaces/secrets/NAME", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) }, @@ -331,7 +331,7 @@ func TestCodespacesService_DeleteSecret(t *testing.T) { { name: "Org", handleFunc: func(mux *http.ServeMux) { - mux.HandleFunc("/orgs/o/codespaces/secrets/NAME", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o/codespaces/secrets/NAME", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) }, @@ -346,7 +346,7 @@ func TestCodespacesService_DeleteSecret(t *testing.T) { { name: "Repo", handleFunc: func(mux *http.ServeMux) { - mux.HandleFunc("/repos/o/r/codespaces/secrets/NAME", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/codespaces/secrets/NAME", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) }, @@ -579,7 +579,7 @@ func TestCodespacesService_SetSelectedReposForSecret(t *testing.T) { { name: "User", handleFunc: func(mux *http.ServeMux) { - mux.HandleFunc("/user/codespaces/secrets/NAME/repositories", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/user/codespaces/secrets/NAME/repositories", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") testHeader(t, r, "Content-Type", "application/json") testBody(t, r, `{"selected_repository_ids":[64780797]}`+"\n") @@ -593,7 +593,7 @@ func TestCodespacesService_SetSelectedReposForSecret(t *testing.T) { { name: "Org", handleFunc: func(mux *http.ServeMux) { - mux.HandleFunc("/orgs/o/codespaces/secrets/NAME/repositories", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o/codespaces/secrets/NAME/repositories", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") testHeader(t, r, "Content-Type", "application/json") testBody(t, r, `{"selected_repository_ids":[64780797]}`+"\n") @@ -650,7 +650,7 @@ func TestCodespacesService_AddSelectedReposForSecret(t *testing.T) { { name: "User", handleFunc: func(mux *http.ServeMux) { - mux.HandleFunc("/user/codespaces/secrets/NAME/repositories/1234", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/user/codespaces/secrets/NAME/repositories/1234", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") }) }, @@ -662,7 +662,7 @@ func TestCodespacesService_AddSelectedReposForSecret(t *testing.T) { { name: "Org", handleFunc: func(mux *http.ServeMux) { - mux.HandleFunc("/orgs/o/codespaces/secrets/NAME/repositories/1234", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o/codespaces/secrets/NAME/repositories/1234", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") }) }, @@ -717,7 +717,7 @@ func TestCodespacesService_RemoveSelectedReposFromSecret(t *testing.T) { { name: "User", handleFunc: func(mux *http.ServeMux) { - mux.HandleFunc("/user/codespaces/secrets/NAME/repositories/1234", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/user/codespaces/secrets/NAME/repositories/1234", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) }, @@ -729,7 +729,7 @@ func TestCodespacesService_RemoveSelectedReposFromSecret(t *testing.T) { { name: "Org", handleFunc: func(mux *http.ServeMux) { - mux.HandleFunc("/orgs/o/codespaces/secrets/NAME/repositories/1234", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o/codespaces/secrets/NAME/repositories/1234", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) }, diff --git a/github/codespaces_test.go b/github/codespaces_test.go index 64146ec848c..1b9e61da168 100644 --- a/github/codespaces_test.go +++ b/github/codespaces_test.go @@ -272,7 +272,7 @@ func TestCodespacesService_Delete(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/user/codespaces/codespace_1", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/user/codespaces/codespace_1", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) diff --git a/github/dependabot_secrets_test.go b/github/dependabot_secrets_test.go index 21f72ca22a7..7b0055dc298 100644 --- a/github/dependabot_secrets_test.go +++ b/github/dependabot_secrets_test.go @@ -204,7 +204,7 @@ func TestDependabotService_DeleteRepoSecret(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repos/o/r/dependabot/secrets/NAME", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/dependabot/secrets/NAME", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) @@ -425,7 +425,7 @@ func TestDependabotService_SetSelectedReposForOrgSecret(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/orgs/o/dependabot/secrets/NAME/repositories", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o/dependabot/secrets/NAME/repositories", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") testHeader(t, r, "Content-Type", "application/json") testBody(t, r, `{"selected_repository_ids":[64780797]}`+"\n") @@ -452,7 +452,7 @@ func TestDependabotService_AddSelectedRepoToOrgSecret(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/orgs/o/dependabot/secrets/NAME/repositories/1234", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o/dependabot/secrets/NAME/repositories/1234", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") }) @@ -478,7 +478,7 @@ func TestDependabotService_RemoveSelectedRepoFromOrgSecret(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/orgs/o/dependabot/secrets/NAME/repositories/1234", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o/dependabot/secrets/NAME/repositories/1234", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) @@ -504,7 +504,7 @@ func TestDependabotService_DeleteOrgSecret(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/orgs/o/dependabot/secrets/NAME", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o/dependabot/secrets/NAME", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) diff --git a/github/enterprise_actions_runner_groups_test.go b/github/enterprise_actions_runner_groups_test.go index e4d2bfffc2f..29623f66c5b 100644 --- a/github/enterprise_actions_runner_groups_test.go +++ b/github/enterprise_actions_runner_groups_test.go @@ -153,7 +153,7 @@ func TestEnterpriseService_DeleteRunnerGroup(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/enterprises/o/actions/runner-groups/2", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/enterprises/o/actions/runner-groups/2", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) @@ -328,7 +328,7 @@ func TestEnterpriseService_SetOrganizationAccessRunnerGroup(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/enterprises/o/actions/runner-groups/2/organizations", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/enterprises/o/actions/runner-groups/2/organizations", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") }) @@ -360,7 +360,7 @@ func TestEnterpriseService_AddOrganizationAccessRunnerGroup(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/enterprises/o/actions/runner-groups/2/organizations/42", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/enterprises/o/actions/runner-groups/2/organizations/42", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") }) @@ -385,7 +385,7 @@ func TestEnterpriseService_RemoveOrganizationAccessRunnerGroup(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/enterprises/o/actions/runner-groups/2/organizations/42", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/enterprises/o/actions/runner-groups/2/organizations/42", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) @@ -453,7 +453,7 @@ func TestEnterpriseService_SetEnterpriseRunnerGroupRunners(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/enterprises/o/actions/runner-groups/2/runners", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/enterprises/o/actions/runner-groups/2/runners", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") }) @@ -485,7 +485,7 @@ func TestEnterpriseService_AddEnterpriseRunnerGroupRunners(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/enterprises/o/actions/runner-groups/2/runners/42", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/enterprises/o/actions/runner-groups/2/runners/42", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") }) @@ -510,7 +510,7 @@ func TestEnterpriseService_RemoveEnterpriseRunnerGroupRunners(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/enterprises/o/actions/runner-groups/2/runners/42", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/enterprises/o/actions/runner-groups/2/runners/42", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) diff --git a/github/enterprise_actions_runners_test.go b/github/enterprise_actions_runners_test.go index dd714078f94..8202c9072b6 100644 --- a/github/enterprise_actions_runners_test.go +++ b/github/enterprise_actions_runners_test.go @@ -186,7 +186,7 @@ func TestEnterpriseService_RemoveRunner(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/enterprises/o/actions/runners/21", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/enterprises/o/actions/runners/21", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) diff --git a/github/enterprise_code_security_and_analysis_test.go b/github/enterprise_code_security_and_analysis_test.go index 6080299b723..57f3e65c9d3 100644 --- a/github/enterprise_code_security_and_analysis_test.go +++ b/github/enterprise_code_security_and_analysis_test.go @@ -78,7 +78,7 @@ func TestEnterpriseService_UpdateCodeSecurityAndAnalysis(t *testing.T) { SecretScanningValidityChecksEnabled: Ptr(true), } - mux.HandleFunc("/enterprises/e/code_security_and_analysis", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/enterprises/e/code_security_and_analysis", func(_ http.ResponseWriter, r *http.Request) { v := new(EnterpriseSecurityAnalysisSettings) assertNilError(t, json.NewDecoder(r.Body).Decode(v)) @@ -111,7 +111,7 @@ func TestEnterpriseService_EnableAdvancedSecurity(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/enterprises/e/advanced_security/enable_all", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/enterprises/e/advanced_security/enable_all", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") }) diff --git a/github/enterprise_manage_ghes_config_test.go b/github/enterprise_manage_ghes_config_test.go index 6fb0f526a25..4b662b4a0a0 100644 --- a/github/enterprise_manage_ghes_config_test.go +++ b/github/enterprise_manage_ghes_config_test.go @@ -603,7 +603,7 @@ func TestEnterpriseService_InitialConfig(t *testing.T) { Password: "password", } - mux.HandleFunc("/manage/v1/config/init", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/manage/v1/config/init", func(_ http.ResponseWriter, r *http.Request) { v := new(InitialConfigOptions) assertNilError(t, json.NewDecoder(r.Body).Decode(v)) diff --git a/github/enterprise_network_configurations_test.go b/github/enterprise_network_configurations_test.go index 74555997427..1c520aaff0f 100644 --- a/github/enterprise_network_configurations_test.go +++ b/github/enterprise_network_configurations_test.go @@ -336,7 +336,7 @@ func TestEnterpriseService_DeleteEnterpriseNetworkConfiguration(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/enterprises/e/network-configurations/123456789ABCDEF", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/enterprises/e/network-configurations/123456789ABCDEF", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) diff --git a/github/enterprise_properties_test.go b/github/enterprise_properties_test.go index 4f44d60f217..3155f9669bc 100644 --- a/github/enterprise_properties_test.go +++ b/github/enterprise_properties_test.go @@ -260,7 +260,7 @@ func TestEnterpriseService_RemoveCustomProperty(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/enterprises/e/properties/schema/name", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/enterprises/e/properties/schema/name", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) diff --git a/github/enterprise_rules_test.go b/github/enterprise_rules_test.go index 6e54948a908..d3e83a2af20 100644 --- a/github/enterprise_rules_test.go +++ b/github/enterprise_rules_test.go @@ -1840,7 +1840,7 @@ func TestEnterpriseService_DeleteRepositoryRuleset(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/enterprises/e/rulesets/84", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/enterprises/e/rulesets/84", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) diff --git a/github/gists_comments_test.go b/github/gists_comments_test.go index 94c07a8c5fe..c3b89c863c6 100644 --- a/github/gists_comments_test.go +++ b/github/gists_comments_test.go @@ -272,7 +272,7 @@ func TestGistsService_DeleteComment(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/gists/1/comments/2", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/gists/1/comments/2", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) diff --git a/github/gists_test.go b/github/gists_test.go index c6ee6d0f661..c7b1b88e98e 100644 --- a/github/gists_test.go +++ b/github/gists_test.go @@ -724,7 +724,7 @@ func TestGistsService_Delete(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/gists/1", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/gists/1", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) @@ -758,7 +758,7 @@ func TestGistsService_Star(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/gists/1/star", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/gists/1/star", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") }) @@ -792,7 +792,7 @@ func TestGistsService_Unstar(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/gists/1/star", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/gists/1/star", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) diff --git a/github/git_commits_test.go b/github/git_commits_test.go index f0ad44b6a64..9fd7309a3ff 100644 --- a/github/git_commits_test.go +++ b/github/git_commits_test.go @@ -32,7 +32,7 @@ func mockSigner(t *testing.T, signature string, emitErr error, wantMessage strin } func uncalledSigner(t *testing.T) MessageSignerFunc { - return func(w io.Writer, r io.Reader) error { + return func(io.Writer, io.Reader) error { t.Error("MessageSignerFunc should not be called") return nil } diff --git a/github/git_refs_test.go b/github/git_refs_test.go index 389b23c0c29..0dc62b09fe7 100644 --- a/github/git_refs_test.go +++ b/github/git_refs_test.go @@ -556,7 +556,7 @@ func TestGitService_DeleteRef(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repos/o/r/git/refs/heads/b", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/git/refs/heads/b", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) diff --git a/github/github.go b/github/github.go index 8f3f3e431ae..89c6ea4ef73 100644 --- a/github/github.go +++ b/github/github.go @@ -409,7 +409,7 @@ func (c *Client) initialize() { c.clientIgnoreRedirects.Transport = c.client.Transport c.clientIgnoreRedirects.Timeout = c.client.Timeout c.clientIgnoreRedirects.Jar = c.client.Jar - c.clientIgnoreRedirects.CheckRedirect = func(req *http.Request, via []*http.Request) error { + c.clientIgnoreRedirects.CheckRedirect = func(*http.Request, []*http.Request) error { return http.ErrUseLastResponse } if c.BaseURL == nil { diff --git a/github/github_test.go b/github/github_test.go index 08a6eaaf6fc..95c7fb2a3c4 100644 --- a/github/github_test.go +++ b/github/github_test.go @@ -357,7 +357,7 @@ func TestWithAuthToken(t *testing.T) { } gotReq := false headerVal := "" - srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + srv := httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) { gotReq = true headerVal = r.Header.Get("Authorization") })) @@ -1086,7 +1086,7 @@ func TestDo_httpError(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) { http.Error(w, "Bad Request", 400) }) @@ -1129,7 +1129,7 @@ func TestDo_preservesResponseInHTTPError(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) { w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusNotFound) fmt.Fprintf(w, `{ @@ -1198,7 +1198,7 @@ func TestDo_rateLimit(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) { w.Header().Set(headerRateLimit, "60") w.Header().Set(headerRateRemaining, "59") w.Header().Set(headerRateUsed, "1") @@ -1312,7 +1312,7 @@ func TestDo_rateLimit_errorResponse(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) { w.Header().Set(headerRateLimit, "60") w.Header().Set(headerRateRemaining, "59") w.Header().Set(headerRateUsed, "1") @@ -1353,7 +1353,7 @@ func TestDo_rateLimit_rateLimitError(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) { w.Header().Set(headerRateLimit, "60") w.Header().Set(headerRateRemaining, "0") w.Header().Set(headerRateUsed, "60") @@ -1403,7 +1403,7 @@ func TestDo_rateLimit_noNetworkCall(t *testing.T) { reset := time.Now().UTC().Add(time.Minute).Round(time.Second) // Rate reset is a minute from now, with 1 second precision. - mux.HandleFunc("/first", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/first", func(w http.ResponseWriter, _ *http.Request) { w.Header().Set(headerRateLimit, "60") w.Header().Set(headerRateRemaining, "0") w.Header().Set(headerRateUsed, "60") @@ -1418,7 +1418,7 @@ func TestDo_rateLimit_noNetworkCall(t *testing.T) { }) madeNetworkCall := false - mux.HandleFunc("/second", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/second", func(http.ResponseWriter, *http.Request) { madeNetworkCall = true }) @@ -1470,7 +1470,7 @@ func TestDo_rateLimit_ignoredFromCache(t *testing.T) { reset := time.Now().UTC().Add(time.Minute).Round(time.Second) // Rate reset is a minute from now, with 1 second precision. // By adding the X-From-Cache header we pretend this is served from a cache. - mux.HandleFunc("/first", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/first", func(w http.ResponseWriter, _ *http.Request) { w.Header().Set("X-From-Cache", "1") w.Header().Set(headerRateLimit, "60") w.Header().Set(headerRateRemaining, "0") @@ -1486,7 +1486,7 @@ func TestDo_rateLimit_ignoredFromCache(t *testing.T) { }) madeNetworkCall := false - mux.HandleFunc("/second", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/second", func(http.ResponseWriter, *http.Request) { madeNetworkCall = true }) @@ -1518,7 +1518,7 @@ func TestDo_rateLimit_sleepUntilResponseResetLimit(t *testing.T) { reset := time.Now().UTC().Add(time.Second) var firstRequest = true - mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) { if firstRequest { firstRequest = false w.Header().Set(headerRateLimit, "60") @@ -1563,7 +1563,7 @@ func TestDo_rateLimit_sleepUntilResponseResetLimitRetryOnce(t *testing.T) { reset := time.Now().UTC().Add(time.Second) requestCount := 0 - mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) { requestCount++ w.Header().Set(headerRateLimit, "60") w.Header().Set(headerRateRemaining, "0") @@ -1597,7 +1597,7 @@ func TestDo_rateLimit_sleepUntilClientResetLimit(t *testing.T) { reset := time.Now().UTC().Add(time.Second) client.rateLimits[CoreCategory] = Rate{Limit: 5000, Remaining: 0, Reset: Timestamp{reset}} requestCount := 0 - mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) { requestCount++ w.Header().Set(headerRateLimit, "5000") w.Header().Set(headerRateRemaining, "5000") @@ -1630,7 +1630,7 @@ func TestDo_rateLimit_abortSleepContextCancelled(t *testing.T) { // We use a 1 minute reset time to ensure the sleep is not completed. reset := time.Now().UTC().Add(time.Minute) requestCount := 0 - mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) { requestCount++ w.Header().Set(headerRateLimit, "60") w.Header().Set(headerRateRemaining, "0") @@ -1665,7 +1665,7 @@ func TestDo_rateLimit_abortSleepContextCancelledClientLimit(t *testing.T) { reset := time.Now().UTC().Add(time.Minute) client.rateLimits[CoreCategory] = Rate{Limit: 5000, Remaining: 0, Reset: Timestamp{reset}} requestCount := 0 - mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) { requestCount++ w.Header().Set(headerRateLimit, "5000") w.Header().Set(headerRateRemaining, "5000") @@ -1698,7 +1698,7 @@ func TestDo_rateLimit_abuseRateLimitError(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) { w.Header().Set("Content-Type", "application/json; charset=utf-8") w.WriteHeader(http.StatusForbidden) // When the abuse rate limit error is of the "temporarily blocked from content creation" type, @@ -1731,7 +1731,7 @@ func TestDo_rateLimit_abuseRateLimitErrorEnterprise(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) { w.Header().Set("Content-Type", "application/json; charset=utf-8") w.WriteHeader(http.StatusForbidden) // When the abuse rate limit error is of the "temporarily blocked from content creation" type, @@ -1765,7 +1765,7 @@ func TestDo_rateLimit_abuseRateLimitError_retryAfter(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) { w.Header().Set("Content-Type", "application/json; charset=utf-8") w.Header().Set(headerRetryAfter, "123") // Retry after value of 123 seconds. w.WriteHeader(http.StatusForbidden) @@ -1821,7 +1821,7 @@ func TestDo_rateLimit_abuseRateLimitError_xRateLimitReset(t *testing.T) { // x-ratelimit-reset value of 123 seconds into the future. blockUntil := time.Now().Add(time.Duration(123) * time.Second).Unix() - mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) { w.Header().Set("Content-Type", "application/json; charset=utf-8") w.Header().Set(headerRateReset, strconv.Itoa(int(blockUntil))) w.Header().Set(headerRateRemaining, "1") // set remaining to a value > 0 to distinct from a primary rate limit @@ -1881,7 +1881,7 @@ func TestDo_rateLimit_abuseRateLimitError_maxDuration(t *testing.T) { // x-ratelimit-reset value of 1h into the future, to make sure we are way over the max wait time duration. blockUntil := time.Now().Add(1 * time.Hour).Unix() - mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) { w.Header().Set("Content-Type", "application/json; charset=utf-8") w.Header().Set(headerRateReset, strconv.Itoa(int(blockUntil))) w.Header().Set(headerRateRemaining, "1") // set remaining to a value > 0 to distinct from a primary rate limit @@ -1916,7 +1916,7 @@ func TestDo_noContent(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusNoContent) }) @@ -2634,7 +2634,7 @@ func TestUnauthenticatedRateLimitedTransport(t *testing.T) { client, mux, _ := setup(t) clientID, clientSecret := "id", "secret" - mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/", func(_ http.ResponseWriter, r *http.Request) { id, secret, ok := r.BasicAuth() if !ok { t.Errorf("request does not contain basic auth credentials") @@ -2708,7 +2708,7 @@ func TestBasicAuthTransport(t *testing.T) { username, password, otp := "u", "p", "123456" - mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/", func(_ http.ResponseWriter, r *http.Request) { u, p, ok := r.BasicAuth() if !ok { t.Errorf("request does not contain basic auth credentials") diff --git a/github/interactions_orgs_test.go b/github/interactions_orgs_test.go index d482cb6cea9..e24d37024dd 100644 --- a/github/interactions_orgs_test.go +++ b/github/interactions_orgs_test.go @@ -99,7 +99,7 @@ func TestInteractionsService_RemoveRestrictionsFromOrg(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/orgs/o/interaction-limits", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o/interaction-limits", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") testHeader(t, r, "Accept", mediaTypeInteractionRestrictionsPreview) }) diff --git a/github/interactions_repos_test.go b/github/interactions_repos_test.go index 6107986b93a..2d5142cedb7 100644 --- a/github/interactions_repos_test.go +++ b/github/interactions_repos_test.go @@ -99,7 +99,7 @@ func TestInteractionsService_RemoveRestrictionsFromRepo(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repos/o/r/interaction-limits", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/interaction-limits", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") testHeader(t, r, "Accept", mediaTypeInteractionRestrictionsPreview) }) diff --git a/github/issues_assignees_test.go b/github/issues_assignees_test.go index 88f0e0e42b3..06c91a07966 100644 --- a/github/issues_assignees_test.go +++ b/github/issues_assignees_test.go @@ -65,7 +65,7 @@ func TestIssuesService_IsAssignee_true(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repos/o/r/assignees/u", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/assignees/u", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") }) diff --git a/github/issues_comments_test.go b/github/issues_comments_test.go index aa9ed2b1146..056c70642b0 100644 --- a/github/issues_comments_test.go +++ b/github/issues_comments_test.go @@ -265,7 +265,7 @@ func TestIssuesService_DeleteComment(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repos/o/r/issues/comments/1", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/issues/comments/1", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) diff --git a/github/issues_labels_test.go b/github/issues_labels_test.go index fd14153b6ab..a607bf4fb19 100644 --- a/github/issues_labels_test.go +++ b/github/issues_labels_test.go @@ -215,7 +215,7 @@ func TestIssuesService_DeleteLabel(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repos/o/r/labels/n", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/labels/n", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) @@ -351,7 +351,7 @@ func TestIssuesService_RemoveLabelForIssue(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repos/o/r/issues/1/labels/l", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/issues/1/labels/l", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) @@ -438,7 +438,7 @@ func TestIssuesService_RemoveLabelsForIssue(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repos/o/r/issues/1/labels", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/issues/1/labels", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) diff --git a/github/issues_milestones_test.go b/github/issues_milestones_test.go index 8b6e17e4ea7..22fa49ec10c 100644 --- a/github/issues_milestones_test.go +++ b/github/issues_milestones_test.go @@ -220,7 +220,7 @@ func TestIssuesService_DeleteMilestone(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repos/o/r/milestones/1", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/milestones/1", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) diff --git a/github/messages_test.go b/github/messages_test.go index 3c8cedfeab8..b414a9e6a93 100644 --- a/github/messages_test.go +++ b/github/messages_test.go @@ -199,7 +199,7 @@ func TestValidatePayload_NoSecretKey(t *testing.T) { // badReader satisfies io.Reader but always returns an error. type badReader struct{} -func (b *badReader) Read(p []byte) (int, error) { +func (b *badReader) Read([]byte) (int, error) { return 0, errors.New("bad reader") } diff --git a/github/migrations.go b/github/migrations.go index 766c4c38e1c..2bc7af8da00 100644 --- a/github/migrations.go +++ b/github/migrations.go @@ -181,7 +181,7 @@ func (s *MigrationService) MigrationArchiveURL(ctx context.Context, org string, // Disable the redirect mechanism because AWS fails if the GitHub auth token is provided. var loc string saveRedirect := s.client.client.CheckRedirect - s.client.client.CheckRedirect = func(req *http.Request, via []*http.Request) error { + s.client.client.CheckRedirect = func(req *http.Request, _ []*http.Request) error { loc = req.URL.String() return errors.New("disable redirect") } diff --git a/github/migrations_user.go b/github/migrations_user.go index a7bd79499a2..58e780ea7bb 100644 --- a/github/migrations_user.go +++ b/github/migrations_user.go @@ -172,7 +172,7 @@ func (s *MigrationService) UserMigrationArchiveURL(ctx context.Context, id int64 var loc string originalRedirect := s.client.client.CheckRedirect - s.client.client.CheckRedirect = func(req *http.Request, via []*http.Request) error { + s.client.client.CheckRedirect = func(req *http.Request, _ []*http.Request) error { loc = req.URL.String() return http.ErrUseLastResponse } diff --git a/github/orgs_hooks_test.go b/github/orgs_hooks_test.go index 3b3b8bff91c..aec8dda8e59 100644 --- a/github/orgs_hooks_test.go +++ b/github/orgs_hooks_test.go @@ -208,7 +208,7 @@ func TestOrganizationsService_PingHook(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/orgs/o/hooks/1/pings", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o/hooks/1/pings", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") }) @@ -233,7 +233,7 @@ func TestOrganizationsService_DeleteHook(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/orgs/o/hooks/1", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o/hooks/1", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) diff --git a/github/orgs_issue_types_test.go b/github/orgs_issue_types_test.go index 7775b4f5ef2..57c731a35d2 100644 --- a/github/orgs_issue_types_test.go +++ b/github/orgs_issue_types_test.go @@ -216,7 +216,7 @@ func TestOrganizationsService_DeleteIssueType(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/orgs/o/issue-types/410", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o/issue-types/410", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) diff --git a/github/orgs_members_test.go b/github/orgs_members_test.go index 71c7fbef3a7..dbdb0f284a1 100644 --- a/github/orgs_members_test.go +++ b/github/orgs_members_test.go @@ -263,7 +263,7 @@ func TestOrganizationsService_RemoveMember(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/orgs/o/members/u", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o/members/u", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) @@ -323,7 +323,7 @@ func TestOrganizationsService_PublicizeMembership(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/orgs/o/public_members/u", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o/public_members/u", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") }) @@ -348,7 +348,7 @@ func TestOrganizationsService_ConcealMembership(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/orgs/o/public_members/u", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o/public_members/u", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) diff --git a/github/orgs_network_configurations_test.go b/github/orgs_network_configurations_test.go index 51fec33f30b..9a095066990 100644 --- a/github/orgs_network_configurations_test.go +++ b/github/orgs_network_configurations_test.go @@ -417,7 +417,7 @@ func TestOrganizationsService_DeleteOrgsNetworkConfiguration(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/orgs/o/settings/network-configurations/789ABDCEF123456", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o/settings/network-configurations/789ABDCEF123456", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) diff --git a/github/orgs_outside_collaborators_test.go b/github/orgs_outside_collaborators_test.go index 42b4b770192..7120449c02f 100644 --- a/github/orgs_outside_collaborators_test.go +++ b/github/orgs_outside_collaborators_test.go @@ -70,7 +70,7 @@ func TestOrganizationsService_RemoveOutsideCollaborator(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - handler := func(w http.ResponseWriter, r *http.Request) { + handler := func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") } mux.HandleFunc("/orgs/o/outside_collaborators/u", handler) @@ -134,7 +134,7 @@ func TestOrganizationsService_ConvertMemberToOutsideCollaborator(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - handler := func(w http.ResponseWriter, r *http.Request) { + handler := func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") } mux.HandleFunc("/orgs/o/outside_collaborators/u", handler) diff --git a/github/orgs_packages_test.go b/github/orgs_packages_test.go index 1bc72bc7cdf..329052ba675 100644 --- a/github/orgs_packages_test.go +++ b/github/orgs_packages_test.go @@ -178,7 +178,7 @@ func TestOrganizationsService_DeletePackage(t *testing.T) { client, mux, _ := setup(t) // don't url escape the package name here since mux will convert it to a slash automatically - mux.HandleFunc("/orgs/o/packages/container/hello%2fhello_docker", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o/packages/container/hello%2fhello_docker", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) @@ -208,7 +208,7 @@ func TestOrganizationsService_RestorePackage(t *testing.T) { client, mux, _ := setup(t) // don't url escape the package name here since mux will convert it to a slash automatically - mux.HandleFunc("/orgs/o/packages/container/hello%2Fhello_docker/restore", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o/packages/container/hello%2Fhello_docker/restore", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") }) @@ -372,7 +372,7 @@ func TestOrganizationsService_PackageDeleteVersion(t *testing.T) { client, mux, _ := setup(t) // don't url escape the package name here since mux will convert it to a slash automatically - mux.HandleFunc("/orgs/o/packages/container/hello%2Fhello_docker/versions/45763", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o/packages/container/hello%2Fhello_docker/versions/45763", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) @@ -398,7 +398,7 @@ func TestOrganizationsService_PackageRestoreVersion(t *testing.T) { client, mux, _ := setup(t) // don't url escape the package name here since mux will convert it to a slash automatically - mux.HandleFunc("/orgs/o/packages/container/hello%2Fhello_docker/versions/45763/restore", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o/packages/container/hello%2Fhello_docker/versions/45763/restore", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") }) diff --git a/github/orgs_properties_test.go b/github/orgs_properties_test.go index ceab4525171..e8bf5fe6502 100644 --- a/github/orgs_properties_test.go +++ b/github/orgs_properties_test.go @@ -260,7 +260,7 @@ func TestOrganizationsService_RemoveCustomProperty(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/orgs/o/properties/schema/name", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o/properties/schema/name", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) @@ -449,7 +449,7 @@ func TestOrganizationsService_CreateOrUpdateRepoCustomPropertyValues(t *testing. t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/orgs/o/properties/values", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o/properties/values", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "PATCH") testBody(t, r, `{"repository_names":["repo"],"properties":[{"property_name":"service","value":"string"}]}`+"\n") }) diff --git a/github/orgs_rules_test.go b/github/orgs_rules_test.go index b21ff93b151..d9727fff89a 100644 --- a/github/orgs_rules_test.go +++ b/github/orgs_rules_test.go @@ -1634,7 +1634,7 @@ func TestOrganizationsService_DeleteRepositoryRuleset(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/orgs/o/rulesets/21", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o/rulesets/21", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) diff --git a/github/orgs_security_managers_test.go b/github/orgs_security_managers_test.go index 3ce67d24c03..4886ac74b8d 100644 --- a/github/orgs_security_managers_test.go +++ b/github/orgs_security_managers_test.go @@ -62,7 +62,7 @@ func TestOrganizationsService_AddSecurityManagerTeam(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/orgs/o/security-managers/teams/t", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o/security-managers/teams/t", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") }) @@ -105,7 +105,7 @@ func TestOrganizationsService_RemoveSecurityManagerTeam(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/orgs/o/security-managers/teams/t", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o/security-managers/teams/t", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) diff --git a/github/orgs_test.go b/github/orgs_test.go index 3866ca78773..0e4e425eb8e 100644 --- a/github/orgs_test.go +++ b/github/orgs_test.go @@ -320,7 +320,7 @@ func TestOrganizationsService_Delete(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/orgs/o", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) diff --git a/github/pulls_comments_test.go b/github/pulls_comments_test.go index 3df530662d0..2e5f20b8dc8 100644 --- a/github/pulls_comments_test.go +++ b/github/pulls_comments_test.go @@ -418,7 +418,7 @@ func TestPullRequestsService_DeleteComment(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repos/o/r/pulls/comments/1", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/pulls/comments/1", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) diff --git a/github/pulls_reviewers_test.go b/github/pulls_reviewers_test.go index cfc415ef82f..1642e0f7df1 100644 --- a/github/pulls_reviewers_test.go +++ b/github/pulls_reviewers_test.go @@ -155,7 +155,7 @@ func TestRemoveReviewers(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repos/o/r/pulls/1/requested_reviewers", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/pulls/1/requested_reviewers", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") testBody(t, r, `{"reviewers":["octocat","googlebot"],"team_reviewers":["justice-league"]}`+"\n") }) @@ -176,7 +176,7 @@ func TestRemoveReviewers_teamsOnly(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repos/o/r/pulls/1/requested_reviewers", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/pulls/1/requested_reviewers", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") testBody(t, r, `{"reviewers":[],"team_reviewers":["justice-league"]}`+"\n") }) diff --git a/github/pulls_test.go b/github/pulls_test.go index 4a48bdb08ae..b321b485451 100644 --- a/github/pulls_test.go +++ b/github/pulls_test.go @@ -796,7 +796,7 @@ func TestPullRequestsService_Merge_options(t *testing.T) { for i, test := range tests { madeRequest := false - mux.HandleFunc(fmt.Sprintf("/repos/o/r/pulls/%d/merge", i), func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(fmt.Sprintf("/repos/o/r/pulls/%d/merge", i), func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") testBody(t, r, test.wantBody+"\n") madeRequest = true @@ -815,7 +815,7 @@ func TestPullRequestsService_Merge_Blank_Message(t *testing.T) { madeRequest := false expectedBody := "" - mux.HandleFunc("/repos/o/r/pulls/1/merge", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/pulls/1/merge", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") testBody(t, r, expectedBody+"\n") madeRequest = true diff --git a/github/rate_limit_test.go b/github/rate_limit_test.go index 8e7f2c83563..bd2414d57f6 100644 --- a/github/rate_limit_test.go +++ b/github/rate_limit_test.go @@ -214,7 +214,7 @@ func TestRateLimits_overQuota(t *testing.T) { Used: 1, Reset: Timestamp{time.Now().Add(time.Hour).Local()}, } - mux.HandleFunc("/rate_limit", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/rate_limit", func(w http.ResponseWriter, _ *http.Request) { fmt.Fprint(w, `{"resources":{ "core": {"limit":2,"remaining":1,"used":1,"reset":1372700873}, "search": {"limit":3,"remaining":2,"used":1,"reset":1372700874}, diff --git a/github/repos_actions_access_test.go b/github/repos_actions_access_test.go index c7550dd28ba..f732bd35cb5 100644 --- a/github/repos_actions_access_test.go +++ b/github/repos_actions_access_test.go @@ -55,7 +55,7 @@ func TestRepositoriesService_EditActionsAccessLevel(t *testing.T) { input := &RepositoryActionsAccessLevel{AccessLevel: Ptr("organization")} - mux.HandleFunc("/repos/o/r/actions/permissions/access", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/actions/permissions/access", func(_ http.ResponseWriter, r *http.Request) { v := new(RepositoryActionsAccessLevel) assertNilError(t, json.NewDecoder(r.Body).Decode(v)) diff --git a/github/repos_comments_test.go b/github/repos_comments_test.go index c415b1c3202..bed314c6a0c 100644 --- a/github/repos_comments_test.go +++ b/github/repos_comments_test.go @@ -264,7 +264,7 @@ func TestRepositoriesService_DeleteComment(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repos/o/r/comments/1", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/comments/1", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) diff --git a/github/repos_contents_test.go b/github/repos_contents_test.go index 1db41a4c1d2..e698cc8f528 100644 --- a/github/repos_contents_test.go +++ b/github/repos_contents_test.go @@ -298,7 +298,7 @@ func TestRepositoriesService_DownloadContents_NoDownloadURL(t *testing.T) { fmt.Fprint(w, `[{ "type": "file", "name": "f", - "content": "" + "content": "" }]`) }) @@ -909,7 +909,7 @@ func TestRepositoriesService_GetArchiveLink(t *testing.T) { }) // Add custom round tripper - client.client.Transport = roundTripperFunc(func(r *http.Request) (*http.Response, error) { + client.client.Transport = roundTripperFunc(func(*http.Request) (*http.Response, error) { return nil, errors.New("failed to get archive link") }) testBadOptions(t, methodName, func() (err error) { diff --git a/github/repos_deployment_branch_policies_test.go b/github/repos_deployment_branch_policies_test.go index bbf4499cf9c..4eb9eab7820 100644 --- a/github/repos_deployment_branch_policies_test.go +++ b/github/repos_deployment_branch_policies_test.go @@ -17,7 +17,7 @@ func TestRepositoriesService_ListDeploymentBranchPolicies(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repos/o/r/environments/e/deployment-branch-policies", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/environments/e/deployment-branch-policies", func(w http.ResponseWriter, _ *http.Request) { fmt.Fprint(w, `{"total_count":2, "branch_policies":[{"id":1}, {"id": 2}]}`) }) @@ -52,7 +52,7 @@ func TestRepositoriesService_GetDeploymentBranchPolicy(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repos/o/r/environments/e/deployment-branch-policies/1", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/environments/e/deployment-branch-policies/1", func(w http.ResponseWriter, _ *http.Request) { fmt.Fprint(w, `{"id":1}`) }) @@ -141,7 +141,7 @@ func TestRepositoriesService_DeleteDeploymentBranchPolicy(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repos/o/r/environments/e/deployment-branch-policies/1", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/environments/e/deployment-branch-policies/1", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) diff --git a/github/repos_environments_test.go b/github/repos_environments_test.go index 715012db2f2..73c5cb736d9 100644 --- a/github/repos_environments_test.go +++ b/github/repos_environments_test.go @@ -331,7 +331,7 @@ func TestRepositoriesService_DeleteEnvironment(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repos/o/r/environments/e", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/environments/e", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) diff --git a/github/repos_hooks_test.go b/github/repos_hooks_test.go index 059d5371034..e57a9161332 100644 --- a/github/repos_hooks_test.go +++ b/github/repos_hooks_test.go @@ -218,7 +218,7 @@ func TestRepositoriesService_DeleteHook(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repos/o/r/hooks/1", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/hooks/1", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) @@ -252,7 +252,7 @@ func TestRepositoriesService_PingHook(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repos/o/r/hooks/1/pings", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/hooks/1/pings", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") }) @@ -277,7 +277,7 @@ func TestRepositoriesService_TestHook(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repos/o/r/hooks/1/tests", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/hooks/1/tests", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") }) @@ -570,7 +570,7 @@ func TestRepositoriesService_Subscribe(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/hub", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/hub", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodPost) testHeader(t, r, "Content-Type", "application/x-www-form-urlencoded") testFormValues(t, r, values{ @@ -603,7 +603,7 @@ func TestRepositoriesService_Unsubscribe(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/hub", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/hub", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodPost) testHeader(t, r, "Content-Type", "application/x-www-form-urlencoded") testFormValues(t, r, values{ diff --git a/github/repos_keys_test.go b/github/repos_keys_test.go index af63857116c..e1fecaca0fe 100644 --- a/github/repos_keys_test.go +++ b/github/repos_keys_test.go @@ -162,7 +162,7 @@ func TestRepositoriesService_DeleteKey(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repos/o/r/keys/1", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/keys/1", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) diff --git a/github/repos_pages_test.go b/github/repos_pages_test.go index 31a2ee1b2ee..505f6a8b6c1 100644 --- a/github/repos_pages_test.go +++ b/github/repos_pages_test.go @@ -271,7 +271,7 @@ func TestRepositoriesService_DisablePages(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repos/o/r/pages", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/pages", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") testHeader(t, r, "Accept", mediaTypeEnablePagesAPIPreview) }) diff --git a/github/repos_prereceive_hooks_test.go b/github/repos_prereceive_hooks_test.go index c424c47a9fa..fc1c3e7f606 100644 --- a/github/repos_prereceive_hooks_test.go +++ b/github/repos_prereceive_hooks_test.go @@ -165,7 +165,7 @@ func TestRepositoriesService_DeletePreReceiveHook(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repos/o/r/pre-receive-hooks/1", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/pre-receive-hooks/1", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) diff --git a/github/repos_releases.go b/github/repos_releases.go index 6023f632716..d4b4591bfbb 100644 --- a/github/repos_releases.go +++ b/github/repos_releases.go @@ -355,7 +355,7 @@ func (s *RepositoriesService) DownloadReleaseAsset(ctx context.Context, owner, r var loc string saveRedirect := s.client.client.CheckRedirect - s.client.client.CheckRedirect = func(req *http.Request, via []*http.Request) error { + s.client.client.CheckRedirect = func(req *http.Request, _ []*http.Request) error { loc = req.URL.String() return errors.New("disable redirect") } diff --git a/github/repos_releases_test.go b/github/repos_releases_test.go index 011e8cf67bf..4e777228ad2 100644 --- a/github/repos_releases_test.go +++ b/github/repos_releases_test.go @@ -332,7 +332,7 @@ func TestRepositoriesService_DeleteRelease(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repos/o/r/releases/1", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/releases/1", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) @@ -656,7 +656,7 @@ func TestRepositoriesService_DeleteReleaseAsset(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repos/o/r/releases/assets/1", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/releases/assets/1", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) diff --git a/github/repos_rules_test.go b/github/repos_rules_test.go index 24beb654199..d94d5bb57f5 100644 --- a/github/repos_rules_test.go +++ b/github/repos_rules_test.go @@ -555,7 +555,7 @@ func TestRepositoriesService_DeleteRuleset(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repos/o/repo/rulesets/42", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/repo/rulesets/42", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) diff --git a/github/repos_test.go b/github/repos_test.go index a62711a1454..a7f1b85e827 100644 --- a/github/repos_test.go +++ b/github/repos_test.go @@ -519,7 +519,7 @@ func TestRepositoriesService_Delete(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repos/o/r", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) @@ -1067,7 +1067,7 @@ func TestRepositoriesService_GetBranch_notFound(t *testing.T) { } // Add custom round tripper - client.client.Transport = roundTripperFunc(func(r *http.Request) (*http.Response, error) { + client.client.Transport = roundTripperFunc(func(*http.Request) (*http.Response, error) { return nil, errors.New("failed to get branch") }) @@ -3545,7 +3545,7 @@ func TestRepositoriesService_ListAppRestrictions(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(test.urlPath, func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") }) @@ -3736,7 +3736,7 @@ func TestRepositoriesService_ListTeamRestrictions(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(test.urlPath, func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") }) @@ -3927,7 +3927,7 @@ func TestRepositoriesService_ListUserRestrictions(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(test.urlPath, func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") }) diff --git a/github/scim.go b/github/scim.go index 70f063caa9b..b6b0f6ddd0d 100644 --- a/github/scim.go +++ b/github/scim.go @@ -252,7 +252,7 @@ func (s *SCIMService) DeleteSCIMUserFromOrg(ctx context.Context, org, scimUserID // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/scim#list-provisioned-scim-groups-for-an-enterprise // //meta:operation GET /scim/v2/enterprises/{enterprise}/Groups -func (s *SCIMService) ListSCIMProvisionedGroupsForEnterprise(ctx context.Context, enterprise string, opts *ListSCIMProvisionedIdentitiesOptions) (*SCIMProvisionedGroups, *Response, error) { +func (s *SCIMService) ListSCIMProvisionedGroupsForEnterprise(ctx context.Context, enterprise string, _ *ListSCIMProvisionedIdentitiesOptions) (*SCIMProvisionedGroups, *Response, error) { u := fmt.Sprintf("scim/v2/enterprises/%v/Groups", enterprise) req, err := s.client.NewRequest("GET", u, nil) diff --git a/github/teams_discussion_comments_test.go b/github/teams_discussion_comments_test.go index e8173abcd5a..e49fb9dc9d4 100644 --- a/github/teams_discussion_comments_test.go +++ b/github/teams_discussion_comments_test.go @@ -388,7 +388,7 @@ func TestTeamsService_DeleteComment(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - handlerFunc := func(w http.ResponseWriter, r *http.Request) { + handlerFunc := func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") } diff --git a/github/teams_discussions_test.go b/github/teams_discussions_test.go index 236382e0227..169f85736df 100644 --- a/github/teams_discussions_test.go +++ b/github/teams_discussions_test.go @@ -496,7 +496,7 @@ func TestTeamsService_DeleteDiscussionByID(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/organizations/1/team/2/discussions/3", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/organizations/1/team/2/discussions/3", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) @@ -521,7 +521,7 @@ func TestTeamsService_DeleteDiscussionBySlug(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/orgs/o/teams/s/discussions/3", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o/teams/s/discussions/3", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) diff --git a/github/teams_test.go b/github/teams_test.go index 1e3d3da2980..0c230c121c6 100644 --- a/github/teams_test.go +++ b/github/teams_test.go @@ -411,7 +411,7 @@ func TestTeamsService_DeleteTeamByID(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/organizations/1/team/1", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/organizations/1/team/1", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) @@ -436,7 +436,7 @@ func TestTeamsService_DeleteTeamBySlug(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/orgs/o/teams/s", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/orgs/o/teams/s", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) diff --git a/github/users_emails_test.go b/github/users_emails_test.go index 6c1c73f3ef9..a3bfeddf72f 100644 --- a/github/users_emails_test.go +++ b/github/users_emails_test.go @@ -99,7 +99,7 @@ func TestUsersService_DeleteEmails(t *testing.T) { input := []string{"user@example.com"} - mux.HandleFunc("/user/emails", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/user/emails", func(_ http.ResponseWriter, r *http.Request) { var v []string assertNilError(t, json.NewDecoder(r.Body).Decode(&v)) diff --git a/github/users_followers_test.go b/github/users_followers_test.go index 1ffe5d7c70e..5f0de89ab19 100644 --- a/github/users_followers_test.go +++ b/github/users_followers_test.go @@ -321,7 +321,7 @@ func TestUsersService_Follow(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/user/following/u", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/user/following/u", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") }) @@ -355,7 +355,7 @@ func TestUsersService_Unfollow(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/user/following/u", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/user/following/u", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) diff --git a/github/users_gpg_keys_test.go b/github/users_gpg_keys_test.go index 585ea4c6dbd..a28225c6347 100644 --- a/github/users_gpg_keys_test.go +++ b/github/users_gpg_keys_test.go @@ -169,7 +169,7 @@ func TestUsersService_DeleteGPGKey(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/user/gpg_keys/1", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/user/gpg_keys/1", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) diff --git a/github/users_keys_test.go b/github/users_keys_test.go index 59167a34778..07c43f77506 100644 --- a/github/users_keys_test.go +++ b/github/users_keys_test.go @@ -160,7 +160,7 @@ func TestUsersService_DeleteKey(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/user/keys/1", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/user/keys/1", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) diff --git a/github/users_packages_test.go b/github/users_packages_test.go index 9de73583615..0456254a696 100644 --- a/github/users_packages_test.go +++ b/github/users_packages_test.go @@ -244,7 +244,7 @@ func TestUsersService_Authenticated_DeletePackage(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/user/packages/container/hello_docker", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/user/packages/container/hello_docker", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) @@ -269,7 +269,7 @@ func TestUsersService_specifiedUser_DeletePackage(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/users/u/packages/container/hello_docker", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/users/u/packages/container/hello_docker", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) @@ -294,7 +294,7 @@ func TestUsersService_Authenticated_RestorePackage(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/user/packages/container/hello_docker/restore", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/user/packages/container/hello_docker/restore", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") }) @@ -319,7 +319,7 @@ func TestUsersService_specifiedUser_RestorePackage(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/users/u/packages/container/hello_docker/restore", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/users/u/packages/container/hello_docker/restore", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") }) @@ -602,7 +602,7 @@ func TestUsersService_Authenticated_PackageDeleteVersion(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/user/packages/container/hello_docker/versions/45763", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/user/packages/container/hello_docker/versions/45763", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) @@ -627,7 +627,7 @@ func TestUsersService_specifiedUser_PackageDeleteVersion(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/users/u/packages/container/hello_docker/versions/45763", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/users/u/packages/container/hello_docker/versions/45763", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) @@ -652,7 +652,7 @@ func TestUsersService_Authenticated_PackageRestoreVersion(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/user/packages/container/hello_docker/versions/45763/restore", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/user/packages/container/hello_docker/versions/45763/restore", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") }) @@ -677,7 +677,7 @@ func TestUsersService_specifiedUser_PackageRestoreVersion(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/users/u/packages/container/hello_docker/versions/45763/restore", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/users/u/packages/container/hello_docker/versions/45763/restore", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") }) diff --git a/github/users_ssh_signing_keys_test.go b/github/users_ssh_signing_keys_test.go index 56c082fdb8a..35189c75f89 100644 --- a/github/users_ssh_signing_keys_test.go +++ b/github/users_ssh_signing_keys_test.go @@ -160,7 +160,7 @@ func TestUsersService_DeleteSSHSigningKey(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/user/ssh_signing_keys/1", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/user/ssh_signing_keys/1", func(_ http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") }) diff --git a/scrape/apps.go b/scrape/apps.go index 291a194efa4..2563e17356f 100644 --- a/scrape/apps.go +++ b/scrape/apps.go @@ -53,7 +53,7 @@ func (c *Client) ListOAuthApps(org string) ([]*OAuthApp, error) { } var apps []*OAuthApp - doc.Find(".oauth-application-allowlist ul > li").Each(func(i int, s *goquery.Selection) { + doc.Find(".oauth-application-allowlist ul > li").Each(func(_ int, s *goquery.Selection) { var app OAuthApp app.Name = s.Find(".request-info strong").First().Text() app.Description = s.Find(".request-info .application-description").Text() diff --git a/scrape/apps_test.go b/scrape/apps_test.go index e7f6da6dcd8..06ab9e1394a 100644 --- a/scrape/apps_test.go +++ b/scrape/apps_test.go @@ -38,7 +38,7 @@ func Test_AppRestrictionsEnabled(t *testing.T) { t.Parallel() client, mux := setup(t) - mux.HandleFunc("/organizations/o/settings/oauth_application_policy", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/organizations/o/settings/oauth_application_policy", func(w http.ResponseWriter, _ *http.Request) { copyTestFile(t, w, tt.testFile) }) @@ -57,7 +57,7 @@ func Test_ListOAuthApps(t *testing.T) { t.Parallel() client, mux := setup(t) - mux.HandleFunc("/organizations/e/settings/oauth_application_policy", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/organizations/e/settings/oauth_application_policy", func(w http.ResponseWriter, _ *http.Request) { copyTestFile(t, w, "access-restrictions-enabled.html") }) @@ -94,7 +94,7 @@ func Test_CreateApp(t *testing.T) { t.Parallel() client, mux := setup(t) - mux.HandleFunc("/apps/settings/new", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/apps/settings/new", func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusCreated) }) @@ -112,7 +112,7 @@ func Test_CreateAppWithOrg(t *testing.T) { t.Parallel() client, mux := setup(t) - mux.HandleFunc("/organizations/example/apps/settings/new", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/organizations/example/apps/settings/new", func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusCreated) }) diff --git a/scrape/forms_test.go b/scrape/forms_test.go index 3a7f1b37a2d..52d4d5edbbf 100644 --- a/scrape/forms_test.go +++ b/scrape/forms_test.go @@ -94,13 +94,13 @@ func Test_FetchAndSumbitForm(t *testing.T) { client, mux := setup(t) var submitted bool - mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) { fmt.Fprint(w, `
`) }) - mux.HandleFunc("/submit", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/submit", func(_ http.ResponseWriter, r *http.Request) { err := r.ParseForm() if err != nil { t.Fatalf("error parsing form: %v", err) diff --git a/scrape/payment.go b/scrape/payment.go index fff9a7531fd..d00eaa9e728 100644 --- a/scrape/payment.go +++ b/scrape/payment.go @@ -23,7 +23,7 @@ func (c *Client) OrgPaymentInformation(org string) (PaymentInformation, error) { return info, err } - doc.Find("main h4.mb-1").Each(func(i int, s *goquery.Selection) { + doc.Find("main h4.mb-1").Each(func(_ int, s *goquery.Selection) { name := strings.TrimSpace(strings.ToLower(s.Text())) value := strings.Join(strings.Fields(strings.TrimSpace(s.NextFiltered("p").Text())), " ") diff --git a/tools/sliceofpointers/sliceofpointers.go b/tools/sliceofpointers/sliceofpointers.go index 75639b68b0b..75519996a7c 100644 --- a/tools/sliceofpointers/sliceofpointers.go +++ b/tools/sliceofpointers/sliceofpointers.go @@ -24,7 +24,7 @@ func init() { type SliceOfPointersPlugin struct{} // New returns an analysis.Analyzer to use with golangci-lint. -func New(settings any) (register.LinterPlugin, error) { +func New(_ any) (register.LinterPlugin, error) { return &SliceOfPointersPlugin{}, nil } From c21f2bed95db30eaaffb640734f7c1630d04b433 Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Wed, 25 Jun 2025 19:29:42 +0300 Subject: [PATCH 04/26] chore: Correct typos in comments and tests error messages (#3604) --- github/issues.go | 2 +- github/repos_test.go | 4 ++-- scrape/forms_test.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/github/issues.go b/github/issues.go index 395d64cf44f..2704339adc0 100644 --- a/github/issues.go +++ b/github/issues.go @@ -136,7 +136,7 @@ type PullRequestLinks struct { } // IssueType represents the type of issue. -// For now it shows up when receiveing an Issue event. +// For now it shows up when receiving an Issue event. type IssueType struct { ID *int64 `json:"id,omitempty"` NodeID *string `json:"node_id,omitempty"` diff --git a/github/repos_test.go b/github/repos_test.go index a7f1b85e827..668baecf5f7 100644 --- a/github/repos_test.go +++ b/github/repos_test.go @@ -676,7 +676,7 @@ func TestRepositoriesService_GetAutomatedSecurityFixes(t *testing.T) { ctx := context.Background() fixes, _, err := client.Repositories.GetAutomatedSecurityFixes(ctx, "o", "r") if err != nil { - t.Errorf("Repositories.GetAutomatedSecurityFixes returned errpr: #{err}") + t.Errorf("Repositories.GetAutomatedSecurityFixes returned error: #{err}") } want := &AutomatedSecurityFixes{ @@ -3342,7 +3342,7 @@ func TestRepositoriesService_OptionalSignaturesOnProtectedBranch(t *testing.T) { } } -func TestPullRequestReviewsEnforcementRequest_MarshalJSON_nilDismissalRestirctions(t *testing.T) { +func TestPullRequestReviewsEnforcementRequest_MarshalJSON_nilDismissalRestrictions(t *testing.T) { t.Parallel() req := PullRequestReviewsEnforcementRequest{} diff --git a/scrape/forms_test.go b/scrape/forms_test.go index 52d4d5edbbf..c1f4152c384 100644 --- a/scrape/forms_test.go +++ b/scrape/forms_test.go @@ -89,7 +89,7 @@ func Test_ParseForms(t *testing.T) { } } -func Test_FetchAndSumbitForm(t *testing.T) { +func Test_FetchAndSubmitForm(t *testing.T) { t.Parallel() client, mux := setup(t) var submitted bool From f1b11e1b216e9722c0a097fd41bb8be7aaea41b0 Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Wed, 25 Jun 2025 22:52:03 +0300 Subject: [PATCH 05/26] fix!: Add ListSCIMProvisionedGroupsForEnterpriseOptions (#3601) BREAKING CHANGE: `ListSCIMProvisionedGroupsForEnterprise` now takes `ListSCIMProvisionedGroupsForEnterpriseOptions` instead of `*ListSCIMProvisionedIdentitiesOptions`. --- github/github-accessors.go | 32 ++++++++++++++++++++++++ github/github-accessors_test.go | 44 +++++++++++++++++++++++++++++++++ github/scim.go | 26 ++++++++++++++++++- github/scim_test.go | 13 +++++++++- 4 files changed, 113 insertions(+), 2 deletions(-) diff --git a/github/github-accessors.go b/github/github-accessors.go index 3193aa9943f..135726bca85 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -13454,6 +13454,38 @@ func (l *ListRunnersOptions) GetName() string { return *l.Name } +// GetCount returns the Count field if it's non-nil, zero value otherwise. +func (l *ListSCIMProvisionedGroupsForEnterpriseOptions) GetCount() int { + if l == nil || l.Count == nil { + return 0 + } + return *l.Count +} + +// GetExcludedAttributes returns the ExcludedAttributes field if it's non-nil, zero value otherwise. +func (l *ListSCIMProvisionedGroupsForEnterpriseOptions) GetExcludedAttributes() string { + if l == nil || l.ExcludedAttributes == nil { + return "" + } + return *l.ExcludedAttributes +} + +// GetFilter returns the Filter field if it's non-nil, zero value otherwise. +func (l *ListSCIMProvisionedGroupsForEnterpriseOptions) GetFilter() string { + if l == nil || l.Filter == nil { + return "" + } + return *l.Filter +} + +// GetStartIndex returns the StartIndex field if it's non-nil, zero value otherwise. +func (l *ListSCIMProvisionedGroupsForEnterpriseOptions) GetStartIndex() int { + if l == nil || l.StartIndex == nil { + return 0 + } + return *l.StartIndex +} + // GetCount returns the Count field if it's non-nil, zero value otherwise. func (l *ListSCIMProvisionedIdentitiesOptions) GetCount() int { if l == nil || l.Count == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 1bb42959961..ca2f10ffb92 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -17454,6 +17454,50 @@ func TestListRunnersOptions_GetName(tt *testing.T) { l.GetName() } +func TestListSCIMProvisionedGroupsForEnterpriseOptions_GetCount(tt *testing.T) { + tt.Parallel() + var zeroValue int + l := &ListSCIMProvisionedGroupsForEnterpriseOptions{Count: &zeroValue} + l.GetCount() + l = &ListSCIMProvisionedGroupsForEnterpriseOptions{} + l.GetCount() + l = nil + l.GetCount() +} + +func TestListSCIMProvisionedGroupsForEnterpriseOptions_GetExcludedAttributes(tt *testing.T) { + tt.Parallel() + var zeroValue string + l := &ListSCIMProvisionedGroupsForEnterpriseOptions{ExcludedAttributes: &zeroValue} + l.GetExcludedAttributes() + l = &ListSCIMProvisionedGroupsForEnterpriseOptions{} + l.GetExcludedAttributes() + l = nil + l.GetExcludedAttributes() +} + +func TestListSCIMProvisionedGroupsForEnterpriseOptions_GetFilter(tt *testing.T) { + tt.Parallel() + var zeroValue string + l := &ListSCIMProvisionedGroupsForEnterpriseOptions{Filter: &zeroValue} + l.GetFilter() + l = &ListSCIMProvisionedGroupsForEnterpriseOptions{} + l.GetFilter() + l = nil + l.GetFilter() +} + +func TestListSCIMProvisionedGroupsForEnterpriseOptions_GetStartIndex(tt *testing.T) { + tt.Parallel() + var zeroValue int + l := &ListSCIMProvisionedGroupsForEnterpriseOptions{StartIndex: &zeroValue} + l.GetStartIndex() + l = &ListSCIMProvisionedGroupsForEnterpriseOptions{} + l.GetStartIndex() + l = nil + l.GetStartIndex() +} + func TestListSCIMProvisionedIdentitiesOptions_GetCount(tt *testing.T) { tt.Parallel() var zeroValue int diff --git a/github/scim.go b/github/scim.go index b6b0f6ddd0d..8b3c1c4ee5b 100644 --- a/github/scim.go +++ b/github/scim.go @@ -108,6 +108,26 @@ type ListSCIMProvisionedIdentitiesOptions struct { Filter *string `url:"filter,omitempty"` } +// ListSCIMProvisionedGroupsForEnterpriseOptions represents options for ListSCIMProvisionedGroupsForEnterprise. +// +// GitHub API docs: https://docs.github.com/en/enterprise-cloud@latest/rest/enterprise-admin/scim#list-provisioned-scim-groups-for-an-enterprise--parameters +type ListSCIMProvisionedGroupsForEnterpriseOptions struct { + // Filter specifies the matching results to return. + // Multiple filters are not supported. Possible filters are externalId, id, and displayName. + // For example: ?filter=externalId eq "9138790-10932-109120392-12321". + // (Optional.) + Filter *string `url:"filter,omitempty"` + // ExcludedAttributes excludes the specified attribute from being returned in the results. + // Using this parameter can speed up response time. (Optional.) + ExcludedAttributes *string `url:"excludedAttributes,omitempty"` + // StartIndex used for pagination: the starting index of the first result to return when paginating through values. (Optional.) + // Default: 1. + StartIndex *int `url:"startIndex,omitempty"` + // Count used for pagination: the number of results to return per page. (Optional.) + // Default: 30. + Count *int `url:"count,omitempty"` +} + // ListSCIMProvisionedIdentities lists SCIM provisioned identities. // // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/scim/scim#list-scim-provisioned-identities @@ -252,8 +272,12 @@ func (s *SCIMService) DeleteSCIMUserFromOrg(ctx context.Context, org, scimUserID // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/scim#list-provisioned-scim-groups-for-an-enterprise // //meta:operation GET /scim/v2/enterprises/{enterprise}/Groups -func (s *SCIMService) ListSCIMProvisionedGroupsForEnterprise(ctx context.Context, enterprise string, _ *ListSCIMProvisionedIdentitiesOptions) (*SCIMProvisionedGroups, *Response, error) { +func (s *SCIMService) ListSCIMProvisionedGroupsForEnterprise(ctx context.Context, enterprise string, opts *ListSCIMProvisionedGroupsForEnterpriseOptions) (*SCIMProvisionedGroups, *Response, error) { u := fmt.Sprintf("scim/v2/enterprises/%v/Groups", enterprise) + u, err := addOptions(u, opts) + if err != nil { + return nil, nil, err + } req, err := s.client.NewRequest("GET", u, nil) if err != nil { diff --git a/github/scim_test.go b/github/scim_test.go index 42a6f2331ed..5507e6807fe 100644 --- a/github/scim_test.go +++ b/github/scim_test.go @@ -127,6 +127,12 @@ func TestSCIMService_ListSCIMProvisionedGroups(t *testing.T) { mux.HandleFunc("/scim/v2/enterprises/o/Groups", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") + testFormValues(t, r, values{ + "startIndex": "1", + "excludedAttributes": "members,meta", + "count": "3", + "filter": `externalId eq "00u1dhhb1fkIGP7RL1d8"`, + }) w.WriteHeader(http.StatusOK) _, _ = w.Write([]byte(`{ "schemas": [ @@ -162,7 +168,12 @@ func TestSCIMService_ListSCIMProvisionedGroups(t *testing.T) { }) ctx := context.Background() - opts := &ListSCIMProvisionedIdentitiesOptions{} + opts := &ListSCIMProvisionedGroupsForEnterpriseOptions{ + StartIndex: Ptr(1), + ExcludedAttributes: Ptr("members,meta"), + Count: Ptr(3), + Filter: Ptr(`externalId eq "00u1dhhb1fkIGP7RL1d8"`), + } groups, _, err := client.SCIM.ListSCIMProvisionedGroupsForEnterprise(ctx, "o", opts) if err != nil { t.Errorf("SCIM.ListSCIMProvisionedIdentities returned error: %v", err) From 5862e2450f3c3b8d16b6c5740b81a8080fe15ca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20B=C3=A9langer?= <33942239+leo-belanger@users.noreply.github.com> Date: Thu, 26 Jun 2025 21:27:30 -0400 Subject: [PATCH 06/26] feat: Add organization migration options (#3606) --- github/migrations.go | 18 ++++++++++++++++++ github/migrations_test.go | 2 ++ 2 files changed, 20 insertions(+) diff --git a/github/migrations.go b/github/migrations.go index 2bc7af8da00..b33be5edd29 100644 --- a/github/migrations.go +++ b/github/migrations.go @@ -55,6 +55,14 @@ type MigrationOptions struct { // ExcludeAttachments indicates whether attachments should be excluded from // the migration (to reduce migration archive file size). ExcludeAttachments bool + + // ExcludeReleases indicates whether releases should be excluded from + // the migration (to reduce migration archive file size). + ExcludeReleases bool + + // Exclude is a slice of related items to exclude from the response in order + // to improve performance of the request. Supported values are: "repositories" + Exclude []string } // startMigration represents the body of a StartMigration request. @@ -69,6 +77,14 @@ type startMigration struct { // ExcludeAttachments indicates whether attachments should be excluded from // the migration (to reduce migration archive file size). ExcludeAttachments *bool `json:"exclude_attachments,omitempty"` + + // ExcludeReleases indicates whether releases should be excluded from + // the migration (to reduce migration archive file size). + ExcludeReleases *bool `json:"exclude_releases,omitempty"` + + // Exclude is a slice of related items to exclude from the response in order + // to improve performance of the request. Supported values are: "repositories" + Exclude []string `json:"exclude,omitempty"` } // StartMigration starts the generation of a migration archive. @@ -84,6 +100,8 @@ func (s *MigrationService) StartMigration(ctx context.Context, org string, repos if opts != nil { body.LockRepositories = Ptr(opts.LockRepositories) body.ExcludeAttachments = Ptr(opts.ExcludeAttachments) + body.ExcludeReleases = Ptr(opts.ExcludeReleases) + body.Exclude = append(body.Exclude, opts.Exclude...) } req, err := s.client.NewRequest("POST", u, body) diff --git a/github/migrations_test.go b/github/migrations_test.go index 99604f62d7c..ec187255fd7 100644 --- a/github/migrations_test.go +++ b/github/migrations_test.go @@ -30,6 +30,8 @@ func TestMigrationService_StartMigration(t *testing.T) { opt := &MigrationOptions{ LockRepositories: true, ExcludeAttachments: false, + ExcludeReleases: true, + Exclude: []string{"repositories"}, } ctx := context.Background() got, _, err := client.Migrations.StartMigration(ctx, "o", []string{"r"}, opt) From a2e5acc1251fc429f04fd884c1ef7635304f78f4 Mon Sep 17 00:00:00 2001 From: Guillaume Winter <8502556+DocEmmetBrown@users.noreply.github.com> Date: Fri, 27 Jun 2025 13:29:35 +0200 Subject: [PATCH 07/26] feat: Add new enhanced billing endpoints (#3605) --- github/billing.go | 96 +++++++++++++++++++ github/billing_test.go | 164 ++++++++++++++++++++++++++++++++ github/github-accessors.go | 120 +++++++++++++++++++++++ github/github-accessors_test.go | 153 +++++++++++++++++++++++++++++ 4 files changed, 533 insertions(+) diff --git a/github/billing.go b/github/billing.go index 09b1a5d017a..2ce595d3349 100644 --- a/github/billing.go +++ b/github/billing.go @@ -63,6 +63,46 @@ type AdvancedSecurityCommittersBreakdown struct { LastPushedDate *string `json:"last_pushed_date,omitempty"` } +// UsageReportOptions specifies optional parameters for the enhanced billing platform usage report. +type UsageReportOptions struct { + // If specified, only return results for a single year. The value of year is an integer with four digits representing a year. For example, 2025. + // Default value is the current year. + Year *int `url:"year,omitempty"` + + // If specified, only return results for a single month. The value of month is an integer between 1 and 12. + // If no year is specified the default year is used. + Month *int `url:"month,omitempty"` + + // If specified, only return results for a single day. The value of day is an integer between 1 and 31. + // If no year or month is specified, the default year and month are used. + Day *int `url:"day,omitempty"` + + // If specified, only return results for a single hour. The value of hour is an integer between 0 and 23. + // If no year, month, or day is specified, the default year, month, and day are used. + Hour *int `url:"hour,omitempty"` +} + +// UsageItem represents a single usage item in the enhanced billing platform report. +type UsageItem struct { + Date *string `json:"date"` + Product *string `json:"product"` + SKU *string `json:"sku"` + Quantity *int `json:"quantity"` + UnitType *string `json:"unitType"` + PricePerUnit *float64 `json:"pricePerUnit"` + GrossAmount *float64 `json:"grossAmount"` + DiscountAmount *float64 `json:"discountAmount"` + NetAmount *float64 `json:"netAmount"` + RepositoryName *string `json:"repositoryName,omitempty"` + // Organization name is only used for organization-level reports. + OrganizationName *string `json:"organizationName,omitempty"` +} + +// UsageReport represents the enhanced billing platform usage report response. +type UsageReport struct { + UsageItems []*UsageItem `json:"usageItems,omitempty"` +} + // GetActionsBillingOrg returns the summary of the free and paid GitHub Actions minutes used for an Org. // // GitHub API docs: https://docs.github.com/rest/billing/billing#get-github-actions-billing-for-an-organization @@ -216,3 +256,59 @@ func (s *BillingService) GetStorageBillingUser(ctx context.Context, user string) return storageUserBilling, resp, nil } + +// GetUsageReportOrg returns a report of the total usage for an organization using the enhanced billing platform. +// +// Note: This endpoint is only available to organizations with access to the enhanced billing platform. +// +// GitHub API docs: https://docs.github.com/rest/billing/enhanced-billing#get-billing-usage-report-for-an-organization +// +//meta:operation GET /organizations/{org}/settings/billing/usage +func (s *BillingService) GetUsageReportOrg(ctx context.Context, org string, opts *UsageReportOptions) (*UsageReport, *Response, error) { + u := fmt.Sprintf("organizations/%v/settings/billing/usage", org) + u, err := addOptions(u, opts) + if err != nil { + return nil, nil, err + } + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + usageReport := new(UsageReport) + resp, err := s.client.Do(ctx, req, usageReport) + if err != nil { + return nil, resp, err + } + + return usageReport, resp, nil +} + +// GetUsageReportUser returns a report of the total usage for a user using the enhanced billing platform. +// +// Note: This endpoint is only available to users with access to the enhanced billing platform. +// +// GitHub API docs: https://docs.github.com/rest/billing/enhanced-billing#get-billing-usage-report-for-a-user +// +//meta:operation GET /users/{username}/settings/billing/usage +func (s *BillingService) GetUsageReportUser(ctx context.Context, user string, opts *UsageReportOptions) (*UsageReport, *Response, error) { + u := fmt.Sprintf("users/%v/settings/billing/usage", user) + u, err := addOptions(u, opts) + if err != nil { + return nil, nil, err + } + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + usageReport := new(UsageReport) + resp, err := s.client.Do(ctx, req, usageReport) + if err != nil { + return nil, resp, err + } + + return usageReport, resp, nil +} diff --git a/github/billing_test.go b/github/billing_test.go index 8fb6499c186..3e9c9e7fc42 100644 --- a/github/billing_test.go +++ b/github/billing_test.go @@ -510,3 +510,167 @@ func TestBillingService_GetAdvancedSecurityActiveCommittersOrg_invalidOrg(t *tes _, _, err := client.Billing.GetAdvancedSecurityActiveCommittersOrg(ctx, "%", nil) testURLParseError(t, err) } + +func TestBillingService_GetUsageReportOrg(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + + mux.HandleFunc("/organizations/o/settings/billing/usage", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + testFormValues(t, r, values{ + "year": "2023", + "month": "8", + }) + fmt.Fprint(w, `{ + "usageItems": [ + { + "date": "2023-08-01", + "product": "Actions", + "sku": "Actions Linux", + "quantity": 100, + "unitType": "minutes", + "pricePerUnit": 0.008, + "grossAmount": 0.8, + "discountAmount": 0, + "netAmount": 0.8, + "organizationName": "GitHub", + "repositoryName": "github/example" + } + ] + }`) + }) + + ctx := context.Background() + opts := &UsageReportOptions{ + Year: Ptr(2023), + Month: Ptr(8), + } + report, _, err := client.Billing.GetUsageReportOrg(ctx, "o", opts) + if err != nil { + t.Errorf("Billing.GetUsageReportOrg returned error: %v", err) + } + + want := &UsageReport{ + UsageItems: []*UsageItem{ + { + Date: Ptr("2023-08-01"), + Product: Ptr("Actions"), + SKU: Ptr("Actions Linux"), + Quantity: Ptr(100), + UnitType: Ptr("minutes"), + PricePerUnit: Ptr(0.008), + GrossAmount: Ptr(0.8), + DiscountAmount: Ptr(0.0), + NetAmount: Ptr(0.8), + OrganizationName: Ptr("GitHub"), + RepositoryName: Ptr("github/example"), + }, + }, + } + if !cmp.Equal(report, want) { + t.Errorf("Billing.GetUsageReportOrg returned %+v, want %+v", report, want) + } + + const methodName = "GetUsageReportOrg" + testBadOptions(t, methodName, func() (err error) { + _, _, err = client.Billing.GetUsageReportOrg(ctx, "\n", opts) + return err + }) + + testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { + got, resp, err := client.Billing.GetUsageReportOrg(ctx, "o", nil) + if got != nil { + t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) + } + return resp, err + }) +} + +func TestBillingService_GetUsageReportOrg_invalidOrg(t *testing.T) { + t.Parallel() + client, _, _ := setup(t) + + ctx := context.Background() + _, _, err := client.Billing.GetUsageReportOrg(ctx, "%", nil) + testURLParseError(t, err) +} + +func TestBillingService_GetUsageReportUser(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + + mux.HandleFunc("/users/u/settings/billing/usage", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + testFormValues(t, r, values{ + "day": "15", + }) + fmt.Fprint(w, `{ + "usageItems": [ + { + "date": "2023-08-15", + "product": "Codespaces", + "sku": "Codespaces Linux", + "quantity": 50, + "unitType": "hours", + "pricePerUnit": 0.18, + "grossAmount": 9.0, + "discountAmount": 1.0, + "netAmount": 8.0, + "repositoryName": "user/example" + } + ] + }`) + }) + + ctx := context.Background() + opts := &UsageReportOptions{ + Day: Ptr(15), + } + report, _, err := client.Billing.GetUsageReportUser(ctx, "u", opts) + if err != nil { + t.Errorf("Billing.GetUsageReportUser returned error: %v", err) + } + + want := &UsageReport{ + UsageItems: []*UsageItem{ + { + Date: Ptr("2023-08-15"), + Product: Ptr("Codespaces"), + SKU: Ptr("Codespaces Linux"), + Quantity: Ptr(50), + UnitType: Ptr("hours"), + PricePerUnit: Ptr(0.18), + GrossAmount: Ptr(9.0), + DiscountAmount: Ptr(1.0), + NetAmount: Ptr(8.0), + RepositoryName: Ptr("user/example"), + }, + }, + } + if !cmp.Equal(report, want) { + t.Errorf("Billing.GetUsageReportUser returned %+v, want %+v", report, want) + } + + const methodName = "GetUsageReportUser" + testBadOptions(t, methodName, func() (err error) { + _, _, err = client.Billing.GetUsageReportUser(ctx, "\n", opts) + return err + }) + + testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { + got, resp, err := client.Billing.GetUsageReportUser(ctx, "u", nil) + if got != nil { + t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) + } + return resp, err + }) +} + +func TestBillingService_GetUsageReportUser_invalidUser(t *testing.T) { + t.Parallel() + client, _, _ := setup(t) + + ctx := context.Background() + _, _, err := client.Billing.GetUsageReportUser(ctx, "%", nil) + testURLParseError(t, err) +} diff --git a/github/github-accessors.go b/github/github-accessors.go index 135726bca85..2b832617c85 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -27574,6 +27574,126 @@ func (u *UpdateRunnerGroupRequest) GetVisibility() string { return *u.Visibility } +// GetDate returns the Date field if it's non-nil, zero value otherwise. +func (u *UsageItem) GetDate() string { + if u == nil || u.Date == nil { + return "" + } + return *u.Date +} + +// GetDiscountAmount returns the DiscountAmount field. +func (u *UsageItem) GetDiscountAmount() *float64 { + if u == nil { + return nil + } + return u.DiscountAmount +} + +// GetGrossAmount returns the GrossAmount field. +func (u *UsageItem) GetGrossAmount() *float64 { + if u == nil { + return nil + } + return u.GrossAmount +} + +// GetNetAmount returns the NetAmount field. +func (u *UsageItem) GetNetAmount() *float64 { + if u == nil { + return nil + } + return u.NetAmount +} + +// GetOrganizationName returns the OrganizationName field if it's non-nil, zero value otherwise. +func (u *UsageItem) GetOrganizationName() string { + if u == nil || u.OrganizationName == nil { + return "" + } + return *u.OrganizationName +} + +// GetPricePerUnit returns the PricePerUnit field. +func (u *UsageItem) GetPricePerUnit() *float64 { + if u == nil { + return nil + } + return u.PricePerUnit +} + +// GetProduct returns the Product field if it's non-nil, zero value otherwise. +func (u *UsageItem) GetProduct() string { + if u == nil || u.Product == nil { + return "" + } + return *u.Product +} + +// GetQuantity returns the Quantity field if it's non-nil, zero value otherwise. +func (u *UsageItem) GetQuantity() int { + if u == nil || u.Quantity == nil { + return 0 + } + return *u.Quantity +} + +// GetRepositoryName returns the RepositoryName field if it's non-nil, zero value otherwise. +func (u *UsageItem) GetRepositoryName() string { + if u == nil || u.RepositoryName == nil { + return "" + } + return *u.RepositoryName +} + +// GetSKU returns the SKU field if it's non-nil, zero value otherwise. +func (u *UsageItem) GetSKU() string { + if u == nil || u.SKU == nil { + return "" + } + return *u.SKU +} + +// GetUnitType returns the UnitType field if it's non-nil, zero value otherwise. +func (u *UsageItem) GetUnitType() string { + if u == nil || u.UnitType == nil { + return "" + } + return *u.UnitType +} + +// GetDay returns the Day field if it's non-nil, zero value otherwise. +func (u *UsageReportOptions) GetDay() int { + if u == nil || u.Day == nil { + return 0 + } + return *u.Day +} + +// GetHour returns the Hour field if it's non-nil, zero value otherwise. +func (u *UsageReportOptions) GetHour() int { + if u == nil || u.Hour == nil { + return 0 + } + return *u.Hour +} + +// GetMonth returns the Month field if it's non-nil, zero value otherwise. +func (u *UsageReportOptions) GetMonth() int { + if u == nil || u.Month == nil { + return 0 + } + return *u.Month +} + +// GetYear returns the Year field if it's non-nil, zero value otherwise. +func (u *UsageReportOptions) GetYear() int { + if u == nil || u.Year == nil { + return 0 + } + return *u.Year +} + // GetAssignment returns the Assignment field if it's non-nil, zero value otherwise. func (u *User) GetAssignment() string { if u == nil || u.Assignment == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index ca2f10ffb92..c0b94a55148 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -35456,6 +35456,159 @@ func TestUpdateRunnerGroupRequest_GetVisibility(tt *testing.T) { u.GetVisibility() } +func TestUsageItem_GetDate(tt *testing.T) { + tt.Parallel() + var zeroValue string + u := &UsageItem{Date: &zeroValue} + u.GetDate() + u = &UsageItem{} + u.GetDate() + u = nil + u.GetDate() +} + +func TestUsageItem_GetDiscountAmount(tt *testing.T) { + tt.Parallel() + u := &UsageItem{} + u.GetDiscountAmount() + u = nil + u.GetDiscountAmount() +} + +func TestUsageItem_GetGrossAmount(tt *testing.T) { + tt.Parallel() + u := &UsageItem{} + u.GetGrossAmount() + u = nil + u.GetGrossAmount() +} + +func TestUsageItem_GetNetAmount(tt *testing.T) { + tt.Parallel() + u := &UsageItem{} + u.GetNetAmount() + u = nil + u.GetNetAmount() +} + +func TestUsageItem_GetOrganizationName(tt *testing.T) { + tt.Parallel() + var zeroValue string + u := &UsageItem{OrganizationName: &zeroValue} + u.GetOrganizationName() + u = &UsageItem{} + u.GetOrganizationName() + u = nil + u.GetOrganizationName() +} + +func TestUsageItem_GetPricePerUnit(tt *testing.T) { + tt.Parallel() + u := &UsageItem{} + u.GetPricePerUnit() + u = nil + u.GetPricePerUnit() +} + +func TestUsageItem_GetProduct(tt *testing.T) { + tt.Parallel() + var zeroValue string + u := &UsageItem{Product: &zeroValue} + u.GetProduct() + u = &UsageItem{} + u.GetProduct() + u = nil + u.GetProduct() +} + +func TestUsageItem_GetQuantity(tt *testing.T) { + tt.Parallel() + var zeroValue int + u := &UsageItem{Quantity: &zeroValue} + u.GetQuantity() + u = &UsageItem{} + u.GetQuantity() + u = nil + u.GetQuantity() +} + +func TestUsageItem_GetRepositoryName(tt *testing.T) { + tt.Parallel() + var zeroValue string + u := &UsageItem{RepositoryName: &zeroValue} + u.GetRepositoryName() + u = &UsageItem{} + u.GetRepositoryName() + u = nil + u.GetRepositoryName() +} + +func TestUsageItem_GetSKU(tt *testing.T) { + tt.Parallel() + var zeroValue string + u := &UsageItem{SKU: &zeroValue} + u.GetSKU() + u = &UsageItem{} + u.GetSKU() + u = nil + u.GetSKU() +} + +func TestUsageItem_GetUnitType(tt *testing.T) { + tt.Parallel() + var zeroValue string + u := &UsageItem{UnitType: &zeroValue} + u.GetUnitType() + u = &UsageItem{} + u.GetUnitType() + u = nil + u.GetUnitType() +} + +func TestUsageReportOptions_GetDay(tt *testing.T) { + tt.Parallel() + var zeroValue int + u := &UsageReportOptions{Day: &zeroValue} + u.GetDay() + u = &UsageReportOptions{} + u.GetDay() + u = nil + u.GetDay() +} + +func TestUsageReportOptions_GetHour(tt *testing.T) { + tt.Parallel() + var zeroValue int + u := &UsageReportOptions{Hour: &zeroValue} + u.GetHour() + u = &UsageReportOptions{} + u.GetHour() + u = nil + u.GetHour() +} + +func TestUsageReportOptions_GetMonth(tt *testing.T) { + tt.Parallel() + var zeroValue int + u := &UsageReportOptions{Month: &zeroValue} + u.GetMonth() + u = &UsageReportOptions{} + u.GetMonth() + u = nil + u.GetMonth() +} + +func TestUsageReportOptions_GetYear(tt *testing.T) { + tt.Parallel() + var zeroValue int + u := &UsageReportOptions{Year: &zeroValue} + u.GetYear() + u = &UsageReportOptions{} + u.GetYear() + u = nil + u.GetYear() +} + func TestUser_GetAssignment(tt *testing.T) { tt.Parallel() var zeroValue string From 2e2654608cd71dc07e27ee846991dd57d834c8a9 Mon Sep 17 00:00:00 2001 From: Bart Venter <72999113+bartventer@users.noreply.github.com> Date: Fri, 27 Jun 2025 14:57:43 +0200 Subject: [PATCH 08/26] docs: Update HTTP cache references to RFC 9111 compliant implementation (#3608) --- README.md | 11 +++++++---- github/doc.go | 2 +- github/github.go | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 82e69a9e33c..aa269eb5f20 100644 --- a/README.md +++ b/README.md @@ -263,15 +263,18 @@ rate limit, as well as help speed up your application. `go-github` does not handle conditional requests directly, but is instead designed to work with a caching `http.Transport`. -Typically, an [RFC 7234](https://datatracker.ietf.org/doc/html/rfc7234) -compliant HTTP cache such as [gregjones/httpcache](https://github.com/gregjones/httpcache) +Typically, an [RFC 9111](https://datatracker.ietf.org/doc/html/rfc9111) +compliant HTTP cache such as [bartventer/httpcache](https://github.com/bartventer/httpcache) is recommended, ex: ```go -import "github.com/gregjones/httpcache" +import ( + "github.com/bartventer/httpcache" + _ "github.com/bartventer/httpcache/store/memcache" // Register the in-memory backend +) client := github.NewClient( - httpcache.NewMemoryCacheTransport().Client() + httpcache.NewClient("memcache://"), ).WithAuthToken(os.Getenv("GITHUB_TOKEN")) ``` diff --git a/github/doc.go b/github/doc.go index f85faed839a..844008d57a6 100644 --- a/github/doc.go +++ b/github/doc.go @@ -144,7 +144,7 @@ rate limit, as well as help speed up your application. go-github does not handle conditional requests directly, but is instead designed to work with a caching [http.Transport]. -Typically, an RFC 7234 compliant HTTP cache such as https://github.com/gregjones/httpcache +Typically, an RFC 9111 compliant HTTP cache such as https://github.com/bartventer/httpcache is recommended. Alternatively, the https://github.com/bored-engineer/github-conditional-http-transport package relies on (undocumented) GitHub specific cache logic and is recommended when making requests using short-lived credentials such as a diff --git a/github/github.go b/github/github.go index 89c6ea4ef73..0e2a9950c29 100644 --- a/github/github.go +++ b/github/github.go @@ -895,7 +895,7 @@ func (c *Client) bareDo(ctx context.Context, caller *http.Client, req *http.Requ } // Don't update the rate limits if this was a cached response. - // X-From-Cache is set by https://github.com/gregjones/httpcache + // X-From-Cache is set by https://github.com/bartventer/httpcache if response.Header.Get("X-From-Cache") == "" { c.rateMu.Lock() c.rateLimits[rateLimitCategory] = response.Rate From 0c6bd9186d03bf5e42a6b6b57ac9e3d68c6426df Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Fri, 27 Jun 2025 18:57:22 +0300 Subject: [PATCH 09/26] fix: Remove custom Accept in Apps.ListRepos and Apps.ListUserRepos (#3609) --- github/apps_installation.go | 17 ----------------- github/apps_installation_test.go | 13 ------------- 2 files changed, 30 deletions(-) diff --git a/github/apps_installation.go b/github/apps_installation.go index d430511d074..57d6b4e76ed 100644 --- a/github/apps_installation.go +++ b/github/apps_installation.go @@ -8,7 +8,6 @@ package github import ( "context" "fmt" - "strings" ) // ListRepositories represents the response from the list repos endpoints. @@ -33,14 +32,6 @@ func (s *AppsService) ListRepos(ctx context.Context, opts *ListOptions) (*ListRe return nil, nil, err } - // TODO: remove custom Accept headers when APIs fully launch. - acceptHeaders := []string{ - mediaTypeTopicsPreview, - mediaTypeRepositoryVisibilityPreview, - mediaTypeRepositoryTemplatePreview, - } - req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) - var r *ListRepositories resp, err := s.client.Do(ctx, req, &r) @@ -69,14 +60,6 @@ func (s *AppsService) ListUserRepos(ctx context.Context, id int64, opts *ListOpt return nil, nil, err } - // TODO: remove custom Accept headers when APIs fully launch. - acceptHeaders := []string{ - mediaTypeTopicsPreview, - mediaTypeRepositoryVisibilityPreview, - mediaTypeRepositoryTemplatePreview, - } - req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) - var r *ListRepositories resp, err := s.client.Do(ctx, req, &r) if err != nil { diff --git a/github/apps_installation_test.go b/github/apps_installation_test.go index 48521504f7a..986281e4c85 100644 --- a/github/apps_installation_test.go +++ b/github/apps_installation_test.go @@ -9,7 +9,6 @@ import ( "context" "fmt" "net/http" - "strings" "testing" "github.com/google/go-cmp/cmp" @@ -19,14 +18,8 @@ func TestAppsService_ListRepos(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - wantAcceptHeaders := []string{ - mediaTypeTopicsPreview, - mediaTypeRepositoryVisibilityPreview, - mediaTypeRepositoryTemplatePreview, - } mux.HandleFunc("/installation/repositories", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - testHeader(t, r, "Accept", strings.Join(wantAcceptHeaders, ", ")) testFormValues(t, r, values{ "page": "1", "per_page": "2", @@ -60,14 +53,8 @@ func TestAppsService_ListUserRepos(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - wantAcceptHeaders := []string{ - mediaTypeTopicsPreview, - mediaTypeRepositoryVisibilityPreview, - mediaTypeRepositoryTemplatePreview, - } mux.HandleFunc("/user/installations/1/repositories", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - testHeader(t, r, "Accept", strings.Join(wantAcceptHeaders, ", ")) testFormValues(t, r, values{ "page": "1", "per_page": "2", From 2d29661f94e742773de59c81dd02c3646ce1aa75 Mon Sep 17 00:00:00 2001 From: Guillaume Winter <8502556+DocEmmetBrown@users.noreply.github.com> Date: Mon, 30 Jun 2025 13:40:20 +0200 Subject: [PATCH 10/26] fix: Change `UsageItem.Quantity` from `int` to `float64` (#3610) --- github/billing.go | 2 +- github/billing_test.go | 4 ++-- github/github-accessors.go | 10 +++++----- github/github-accessors_test.go | 5 +---- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/github/billing.go b/github/billing.go index 2ce595d3349..0776358cdb2 100644 --- a/github/billing.go +++ b/github/billing.go @@ -87,7 +87,7 @@ type UsageItem struct { Date *string `json:"date"` Product *string `json:"product"` SKU *string `json:"sku"` - Quantity *int `json:"quantity"` + Quantity *float64 `json:"quantity"` UnitType *string `json:"unitType"` PricePerUnit *float64 `json:"pricePerUnit"` GrossAmount *float64 `json:"grossAmount"` diff --git a/github/billing_test.go b/github/billing_test.go index 3e9c9e7fc42..3c29054840b 100644 --- a/github/billing_test.go +++ b/github/billing_test.go @@ -556,7 +556,7 @@ func TestBillingService_GetUsageReportOrg(t *testing.T) { Date: Ptr("2023-08-01"), Product: Ptr("Actions"), SKU: Ptr("Actions Linux"), - Quantity: Ptr(100), + Quantity: Ptr(100.0), UnitType: Ptr("minutes"), PricePerUnit: Ptr(0.008), GrossAmount: Ptr(0.8), @@ -637,7 +637,7 @@ func TestBillingService_GetUsageReportUser(t *testing.T) { Date: Ptr("2023-08-15"), Product: Ptr("Codespaces"), SKU: Ptr("Codespaces Linux"), - Quantity: Ptr(50), + Quantity: Ptr(50.0), UnitType: Ptr("hours"), PricePerUnit: Ptr(0.18), GrossAmount: Ptr(9.0), diff --git a/github/github-accessors.go b/github/github-accessors.go index 2b832617c85..57e2d07dfc8 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -27630,12 +27630,12 @@ func (u *UsageItem) GetProduct() string { return *u.Product } -// GetQuantity returns the Quantity field if it's non-nil, zero value otherwise. -func (u *UsageItem) GetQuantity() int { - if u == nil || u.Quantity == nil { - return 0 +// GetQuantity returns the Quantity field. +func (u *UsageItem) GetQuantity() *float64 { + if u == nil { + return nil } - return *u.Quantity + return u.Quantity } // GetRepositoryName returns the RepositoryName field if it's non-nil, zero value otherwise. diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index c0b94a55148..1e66350a1d7 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -35523,10 +35523,7 @@ func TestUsageItem_GetProduct(tt *testing.T) { func TestUsageItem_GetQuantity(tt *testing.T) { tt.Parallel() - var zeroValue int - u := &UsageItem{Quantity: &zeroValue} - u.GetQuantity() - u = &UsageItem{} + u := &UsageItem{} u.GetQuantity() u = nil u.GetQuantity() From efe572e611555104da0b13fb8b89165245afb0da Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Mon, 30 Jun 2025 14:44:35 +0300 Subject: [PATCH 11/26] fix: Fix broken URL for `SubIssueService.Remove` endpoint (#3613) --- github/sub_issue.go | 4 ++-- github/sub_issue_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/github/sub_issue.go b/github/sub_issue.go index 8b24adb899b..2effcc5afb0 100644 --- a/github/sub_issue.go +++ b/github/sub_issue.go @@ -49,8 +49,8 @@ type SubIssueRequest struct { // GitHub API docs: https://docs.github.com/rest/issues/sub-issues#remove-sub-issue // //meta:operation DELETE /repos/{owner}/{repo}/issues/{issue_number}/sub_issue -func (s *SubIssueService) Remove(ctx context.Context, owner, repo string, subIssueNumber int64, subIssue SubIssueRequest) (*SubIssue, *Response, error) { - u := fmt.Sprintf("repos/%v/%v/issues/%v/sub_issues", owner, repo, subIssueNumber) +func (s *SubIssueService) Remove(ctx context.Context, owner, repo string, issueNumber int64, subIssue SubIssueRequest) (*SubIssue, *Response, error) { + u := fmt.Sprintf("repos/%v/%v/issues/%v/sub_issue", owner, repo, issueNumber) req, err := s.client.NewRequest("DELETE", u, subIssue) if err != nil { diff --git a/github/sub_issue_test.go b/github/sub_issue_test.go index 9a88b2441d0..72e331c31f7 100644 --- a/github/sub_issue_test.go +++ b/github/sub_issue_test.go @@ -97,7 +97,7 @@ func TestSubIssuesService_Remove(t *testing.T) { input := &SubIssueRequest{SubIssueID: 42} - mux.HandleFunc("/repos/o/r/issues/1/sub_issues", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/issues/1/sub_issue", func(w http.ResponseWriter, r *http.Request) { v := new(SubIssueRequest) assertNilError(t, json.NewDecoder(r.Body).Decode(v)) From d96da2ee947b989823cedffea6ddc582e5b0decb Mon Sep 17 00:00:00 2001 From: Steve Hipwell Date: Mon, 30 Jun 2025 16:57:19 +0100 Subject: [PATCH 12/26] feat: Add DisableRateLimitCheck option to client (#3607) --- README.md | 73 +++++++++++++++++++++++++---------------- github/github.go | 49 +++++++++++++++++----------- github/github_test.go | 76 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 151 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index aa269eb5f20..f45d3730399 100644 --- a/README.md +++ b/README.md @@ -189,54 +189,71 @@ using the installation ID of the GitHub app and authenticate with the OAuth meth ### Rate Limiting ### -GitHub imposes a rate limit on all API clients. Unauthenticated clients are -limited to 60 requests per hour, while authenticated clients can make up to -5,000 requests per hour. The Search API has a custom rate limit. Unauthenticated -clients are limited to 10 requests per minute, while authenticated clients -can make up to 30 requests per minute. To receive the higher rate limit when -making calls that are not issued on behalf of a user, -use `UnauthenticatedRateLimitedTransport`. - -The returned `Response.Rate` value contains the rate limit information +GitHub imposes rate limits on all API clients. The [primary rate limit](https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api#about-primary-rate-limits) +is the limit to the number of REST API requests that a client can make within a +specific amount of time. This limit helps prevent abuse and denial-of-service +attacks, and ensures that the API remains available for all users. Some +endpoints, like the search endpoints, have more restrictive limits. +Unauthenticated clients may request public data but have a low rate limit, +while authenticated clients have rate limits based on the client +identity. + +In addition to primary rate limits, GitHub enforces [secondary rate limits](https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api#about-secondary-rate-limits) +in order to prevent abuse and keep the API available for all users. +Secondary rate limits generally limit the number of concurrent requests that a +client can make. + +The client returned `Response.Rate` value contains the rate limit information from the most recent API call. If a recent enough response isn't -available, you can use `RateLimits` to fetch the most up-to-date rate -limit data for the client. +available, you can use the client `RateLimits` service to fetch the most +up-to-date rate limit data for the client. -To detect an API rate limit error, you can check if its type is `*github.RateLimitError`: +To detect a primary API rate limit error, you can check if the error is a +`RateLimitError`. ```go repos, _, err := client.Repositories.List(ctx, "", nil) -if _, ok := err.(*github.RateLimitError); ok { - log.Println("hit rate limit") +var rateErr *github.RateLimitError +if errors.As(err, &rateError) { + log.Printf("hit primary rate limit, used %d of %d\n", rateErr.Rate.Used, rateErr.rate.Limit) } ``` -Learn more about GitHub rate limiting in -["REST API endpoints for rate limits"](https://docs.github.com/en/rest/rate-limit). - -In addition to these rate limits, GitHub imposes a secondary rate limit on all API clients. -This rate limit prevents clients from making too many concurrent requests. - -To detect an API secondary rate limit error, you can check if its type is `*github.AbuseRateLimitError`: +To detect an API secondary rate limit error, you can check if the error is an +`AbuseRateLimitError`. ```go repos, _, err := client.Repositories.List(ctx, "", nil) -if _, ok := err.(*github.AbuseRateLimitError); ok { - log.Println("hit secondary rate limit") +var rateErr *github.AbuseRateLimitError +if errors.As(err, &rateErr) { + log.Printf("hit secondary rate limit, retry after %v\n", rateErr.RetryAfter) } ``` -Alternatively, you can block until the rate limit is reset by using the `context.WithValue` method: +If you hit the primary rate limit, you can use the `SleepUntilPrimaryRateLimitResetWhenRateLimited` +method to block until the rate limit is reset. ```go repos, _, err := client.Repositories.List(context.WithValue(ctx, github.SleepUntilPrimaryRateLimitResetWhenRateLimited, true), "", nil) ``` -You can use [gofri/go-github-ratelimit](https://github.com/gofri/go-github-ratelimit) to handle -secondary rate limit sleep-and-retry for you, as well as primary rate limit abuse-prevention and callback triggering. +If you need to make a request even if the rate limit has been hit you can use +the `BypassRateLimitCheck` method to bypass the rate limit check and make the +request anyway. + +```go +repos, _, err := client.Repositories.List(context.WithValue(ctx, github.BypassRateLimitCheck, true), "", nil) +``` + +For more advanced use cases, you can use [gofri/go-github-ratelimit](https://github.com/gofri/go-github-ratelimit) +which provides a middleware (`http.RoundTripper`) that handles both the primary +rate limit and secondary rate limit for the GitHub API. In this case you can +set the client `DisableRateLimitCheck` to `true` so the client doesn't track the rate limit usage. -Learn more about GitHub secondary rate limiting in -["About secondary rate limits"](https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api?apiVersion=2022-11-28#about-secondary-rate-limits). +If the client is an [OAuth app](https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api#primary-rate-limit-for-oauth-apps) +you can use the apps higher rate limit to request public data by using the +`UnauthenticatedRateLimitedTransport` to make calls as the app instead of as +the user. ### Accepted Status ### diff --git a/github/github.go b/github/github.go index 0e2a9950c29..481752c5cb9 100644 --- a/github/github.go +++ b/github/github.go @@ -171,6 +171,11 @@ type Client struct { // User agent used when communicating with the GitHub API. UserAgent string + // DisableRateLimitCheck stops the client checking for rate limits or tracking + // them. This is different to setting BypassRateLimitCheck in the context, + // as that still tracks the rate limits. + DisableRateLimitCheck bool + rateMu sync.Mutex rateLimits [Categories]Rate // Rate limits for the client as determined by the most recent API calls. secondaryRateLimitReset time.Time // Secondary rate limit reset for the client as determined by the most recent API calls. @@ -850,21 +855,26 @@ func (c *Client) bareDo(ctx context.Context, caller *http.Client, req *http.Requ req = withContext(ctx, req) - rateLimitCategory := GetRateLimitCategory(req.Method, req.URL.Path) + rateLimitCategory := CoreCategory - if bypass := ctx.Value(BypassRateLimitCheck); bypass == nil { - // If we've hit rate limit, don't make further requests before Reset time. - if err := c.checkRateLimitBeforeDo(req, rateLimitCategory); err != nil { - return &Response{ - Response: err.Response, - Rate: err.Rate, - }, err - } - // If we've hit a secondary rate limit, don't make further requests before Retry After. - if err := c.checkSecondaryRateLimitBeforeDo(req); err != nil { - return &Response{ - Response: err.Response, - }, err + if !c.DisableRateLimitCheck { + rateLimitCategory = GetRateLimitCategory(req.Method, req.URL.Path) + + if bypass := ctx.Value(BypassRateLimitCheck); bypass == nil { + // If we've hit rate limit, don't make further requests before Reset time. + if err := c.checkRateLimitBeforeDo(req, rateLimitCategory); err != nil { + return &Response{ + Response: err.Response, + Rate: err.Rate, + }, err + } + + // If we've hit a secondary rate limit, don't make further requests before Retry After. + if err := c.checkSecondaryRateLimitBeforeDo(req); err != nil { + return &Response{ + Response: err.Response, + }, err + } } } @@ -894,9 +904,10 @@ func (c *Client) bareDo(ctx context.Context, caller *http.Client, req *http.Requ return response, err } - // Don't update the rate limits if this was a cached response. - // X-From-Cache is set by https://github.com/bartventer/httpcache - if response.Header.Get("X-From-Cache") == "" { + // Don't update the rate limits if the client has rate limits disabled or if + // this was a cached response. The X-From-Cache is set by + // https://github.com/bartventer/httpcache if it's enabled. + if !c.DisableRateLimitCheck && response.Header.Get("X-From-Cache") == "" { c.rateMu.Lock() c.rateLimits[rateLimitCategory] = response.Rate c.rateMu.Unlock() @@ -1586,8 +1597,8 @@ that need to use a higher rate limit associated with your OAuth application. This will add the client id and secret as a base64-encoded string in the format ClientID:ClientSecret and apply it as an "Authorization": "Basic" header. -See https://docs.github.com/rest/#unauthenticated-rate-limited-requests for -more information. +See https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api#primary-rate-limit-for-oauth-apps +for more information. */ type UnauthenticatedRateLimitedTransport struct { // ClientID is the GitHub OAuth client ID of the current application, which diff --git a/github/github_test.go b/github/github_test.go index 95c7fb2a3c4..412bd26cdae 100644 --- a/github/github_test.go +++ b/github/github_test.go @@ -251,6 +251,9 @@ func testNewRequestAndDoFailureCategory(t *testing.T, methodName string, client client.BaseURL.Path = "/api-v3/" client.rateLimits[category].Reset.Time = time.Now().Add(10 * time.Minute) resp, err = f() + if client.DisableRateLimitCheck { + return + } if bypass := resp.Request.Context().Value(BypassRateLimitCheck); bypass != nil { return } @@ -1912,6 +1915,79 @@ func TestDo_rateLimit_abuseRateLimitError_maxDuration(t *testing.T) { } } +// Make network call if client has disabled the rate limit check. +func TestDo_rateLimit_disableRateLimitCheck(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + client.DisableRateLimitCheck = true + + reset := time.Now().UTC().Add(60 * time.Second) + client.rateLimits[CoreCategory] = Rate{Limit: 5000, Remaining: 0, Reset: Timestamp{reset}} + requestCount := 0 + mux.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) { + requestCount++ + w.Header().Set(headerRateLimit, "5000") + w.Header().Set(headerRateRemaining, "5000") + w.Header().Set(headerRateUsed, "0") + w.Header().Set(headerRateReset, fmt.Sprint(reset.Add(time.Hour).Unix())) + w.Header().Set(headerRateResource, "core") + w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.WriteHeader(http.StatusOK) + fmt.Fprintln(w, `{}`) + }) + req, _ := client.NewRequest("GET", ".", nil) + ctx := context.Background() + resp, err := client.Do(ctx, req, nil) + if err != nil { + t.Errorf("Do returned unexpected error: %v", err) + } + if got, want := resp.StatusCode, http.StatusOK; got != want { + t.Errorf("Response status code = %v, want %v", got, want) + } + if got, want := requestCount, 1; got != want { + t.Errorf("Expected 1 request, got %d", got) + } + if got, want := client.rateLimits[CoreCategory].Remaining, 0; got != want { + t.Errorf("Expected 0 requests remaining, got %d", got) + } +} + +// Make network call if client has bypassed the rate limit check. +func TestDo_rateLimit_bypassRateLimitCheck(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + + reset := time.Now().UTC().Add(60 * time.Second) + client.rateLimits[CoreCategory] = Rate{Limit: 5000, Remaining: 0, Reset: Timestamp{reset}} + requestCount := 0 + mux.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) { + requestCount++ + w.Header().Set(headerRateLimit, "5000") + w.Header().Set(headerRateRemaining, "5000") + w.Header().Set(headerRateUsed, "0") + w.Header().Set(headerRateReset, fmt.Sprint(reset.Add(time.Hour).Unix())) + w.Header().Set(headerRateResource, "core") + w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.WriteHeader(http.StatusOK) + fmt.Fprintln(w, `{}`) + }) + req, _ := client.NewRequest("GET", ".", nil) + ctx := context.Background() + resp, err := client.Do(context.WithValue(ctx, BypassRateLimitCheck, true), req, nil) + if err != nil { + t.Errorf("Do returned unexpected error: %v", err) + } + if got, want := resp.StatusCode, http.StatusOK; got != want { + t.Errorf("Response status code = %v, want %v", got, want) + } + if got, want := requestCount, 1; got != want { + t.Errorf("Expected 1 request, got %d", got) + } + if got, want := client.rateLimits[CoreCategory].Remaining, 5000; got != want { + t.Errorf("Expected 5000 requests remaining, got %d", got) + } +} + func TestDo_noContent(t *testing.T) { t.Parallel() client, mux, _ := setup(t) From 5e2e19e2dfdcd6ac3b4805a4c9fc15e85e655e72 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Jun 2025 19:06:38 -0400 Subject: [PATCH 13/26] build(deps): bump github.com/alecthomas/kong from 1.11.0 to 1.12.0 in /tools (#3614) --- tools/go.mod | 2 +- tools/go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/go.mod b/tools/go.mod index 0be0cf6c04b..ad95daa30da 100644 --- a/tools/go.mod +++ b/tools/go.mod @@ -3,7 +3,7 @@ module tools go 1.23.0 require ( - github.com/alecthomas/kong v1.11.0 + github.com/alecthomas/kong v1.12.0 github.com/getkin/kin-openapi v0.132.0 github.com/google/go-cmp v0.7.0 github.com/google/go-github/v73 v73.0.0 diff --git a/tools/go.sum b/tools/go.sum index 2f0fa8680ab..951befe4893 100644 --- a/tools/go.sum +++ b/tools/go.sum @@ -1,7 +1,7 @@ github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0= github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= -github.com/alecthomas/kong v1.11.0 h1:y++1gI7jf8O7G7l4LZo5ASFhrhJvzc+WgF/arranEmM= -github.com/alecthomas/kong v1.11.0/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU= +github.com/alecthomas/kong v1.12.0 h1:oKd/0fHSdajj5PfGDd3ScvEvpVJf9mT2mb5r9xYadYM= +github.com/alecthomas/kong v1.12.0/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU= github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc= github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= From eff2bbd83e04dfdb38a9a878f7756e305656a9e2 Mon Sep 17 00:00:00 2001 From: sellskin Date: Tue, 1 Jul 2025 11:12:11 +0800 Subject: [PATCH 14/26] chore: Fix some minor issues in the comments (#3615) --- README.md | 2 +- github/dependency_graph.go | 2 +- github/doc.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f45d3730399..907846821ad 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ The services of a client divide the API into logical chunks and correspond to the structure of the [GitHub API documentation](https://docs.github.com/en/rest). NOTE: Using the [context](https://pkg.go.dev/context) package, one can easily -pass cancelation signals and deadlines to various services of the client for +pass cancellation signals and deadlines to various services of the client for handling a request. In case there is no context available, then `context.Background()` can be used as a starting point. diff --git a/github/dependency_graph.go b/github/dependency_graph.go index b202aafff55..0218c79054f 100644 --- a/github/dependency_graph.go +++ b/github/dependency_graph.go @@ -66,7 +66,7 @@ type SBOMRelationship struct { // Example: "SPDXRef-github-interlynk-io-sbomqs-main-f43c98" SPDXElementID string `json:"spdxElementId"` - // RelatedSpdxElement is the identifier of the related SPDX element. + // RelatedSPDXElement is the identifier of the related SPDX element. // Example: "SPDXRef-golang-github.comspf13-cobra-1.8.1-75c946" RelatedSPDXElement string `json:"relatedSpdxElement"` diff --git a/github/doc.go b/github/doc.go index 844008d57a6..2d7191cc389 100644 --- a/github/doc.go +++ b/github/doc.go @@ -32,7 +32,7 @@ the structure of the GitHub API documentation at https://docs.github.com/rest . NOTE: Using the [context] package, one can easily -pass cancelation signals and deadlines to various services of the client for +pass cancellation signals and deadlines to various services of the client for handling a request. In case there is no context available, then [context.Background] can be used as a starting point. From 21c29760f11a7ba99e8c6b4b3d80d6e855caeddc Mon Sep 17 00:00:00 2001 From: sanjay s Date: Wed, 2 Jul 2025 08:18:48 +0530 Subject: [PATCH 15/26] fix: Handle null assignee in Copilot Seat Billing API response (#3619) --- github/copilot.go | 5 +++++ github/copilot_test.go | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/github/copilot.go b/github/copilot.go index bed83536b41..b4f21ad39aa 100644 --- a/github/copilot.go +++ b/github/copilot.go @@ -203,6 +203,11 @@ func (cp *CopilotSeatDetails) UnmarshalJSON(data []byte) error { cp.PlanType = seatDetail.PlanType switch v := seatDetail.Assignee.(type) { + case nil: + // Assignee can be null according to GitHub API specification. + // See: https://docs.github.com/en/rest/copilot/copilot-user-management?apiVersion=2022-11-28#list-all-copilot-seat-assignments-for-an-organization + // Note: Copilot API is in public preview and subject to change. + cp.Assignee = nil case map[string]any: jsonData, err := json.Marshal(seatDetail.Assignee) if err != nil { diff --git a/github/copilot_test.go b/github/copilot_test.go index ed81761370e..1aeb4308555 100644 --- a/github/copilot_test.go +++ b/github/copilot_test.go @@ -58,6 +58,16 @@ func TestCopilotSeatDetails_UnmarshalJSON(t *testing.T) { want: &CopilotSeatDetails{}, wantErr: true, }, + { + name: "Null Assignee", + data: `{ + "assignee": null + }`, + want: &CopilotSeatDetails{ + Assignee: nil, + }, + wantErr: false, + }, { name: "Invalid Assignee Field Type", data: `{ From bf1d28063eeaf3725de535f65ee0cfca6b964ce8 Mon Sep 17 00:00:00 2001 From: Resplandor <35630904+TheResplandor@users.noreply.github.com> Date: Wed, 2 Jul 2025 05:52:35 +0300 Subject: [PATCH 16/26] fix: Add `ProtectionURL` field to `Repositories.ListBranches` response (#3618) --- github/github-accessors.go | 8 ++++++++ github/github-accessors_test.go | 11 +++++++++++ github/repos.go | 3 ++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/github/github-accessors.go b/github/github-accessors.go index 57e2d07dfc8..2dc33c6a6aa 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -1614,6 +1614,14 @@ func (b *Branch) GetProtection() *Protection { return b.Protection } +// GetProtectionURL returns the ProtectionURL field if it's non-nil, zero value otherwise. +func (b *Branch) GetProtectionURL() string { + if b == nil || b.ProtectionURL == nil { + return "" + } + return *b.ProtectionURL +} + // GetCommit returns the Commit field. func (b *BranchCommit) GetCommit() *Commit { if b == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 1e66350a1d7..6392c967f7c 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -2122,6 +2122,17 @@ func TestBranch_GetProtection(tt *testing.T) { b.GetProtection() } +func TestBranch_GetProtectionURL(tt *testing.T) { + tt.Parallel() + var zeroValue string + b := &Branch{ProtectionURL: &zeroValue} + b.GetProtectionURL() + b = &Branch{} + b.GetProtectionURL() + b = nil + b.GetProtectionURL() +} + func TestBranchCommit_GetCommit(tt *testing.T) { tt.Parallel() b := &BranchCommit{} diff --git a/github/repos.go b/github/repos.go index 71483534363..e4f9cc0c074 100644 --- a/github/repos.go +++ b/github/repos.go @@ -1010,7 +1010,8 @@ type Branch struct { // such as 'List branches'. In such cases, if branch protection is // enabled, Protected will be `true` but this will be nil, and // additional protection details can be obtained by calling GetBranch(). - Protection *Protection `json:"protection,omitempty"` + Protection *Protection `json:"protection,omitempty"` + ProtectionURL *string `json:"protection_url,omitempty"` } // Protection represents a repository branch's protection. From b7589288884b83a65edb83e0de86b67fb94d95c3 Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Fri, 4 Jul 2025 20:17:03 +0300 Subject: [PATCH 17/26] feat: Add digest field to Artifact (#3621) --- github/actions_artifacts.go | 26 +++++++++++++++----------- github/github-accessors.go | 8 ++++++++ github/github-accessors_test.go | 11 +++++++++++ 3 files changed, 34 insertions(+), 11 deletions(-) diff --git a/github/actions_artifacts.go b/github/actions_artifacts.go index 2b560fa05de..73641559db4 100644 --- a/github/actions_artifacts.go +++ b/github/actions_artifacts.go @@ -29,17 +29,21 @@ type ArtifactWorkflowRun struct { // // GitHub API docs: https://docs.github.com/rest/actions/artifacts type Artifact struct { - ID *int64 `json:"id,omitempty"` - NodeID *string `json:"node_id,omitempty"` - Name *string `json:"name,omitempty"` - SizeInBytes *int64 `json:"size_in_bytes,omitempty"` - URL *string `json:"url,omitempty"` - ArchiveDownloadURL *string `json:"archive_download_url,omitempty"` - Expired *bool `json:"expired,omitempty"` - CreatedAt *Timestamp `json:"created_at,omitempty"` - UpdatedAt *Timestamp `json:"updated_at,omitempty"` - ExpiresAt *Timestamp `json:"expires_at,omitempty"` - WorkflowRun *ArtifactWorkflowRun `json:"workflow_run,omitempty"` + ID *int64 `json:"id,omitempty"` + NodeID *string `json:"node_id,omitempty"` + Name *string `json:"name,omitempty"` + SizeInBytes *int64 `json:"size_in_bytes,omitempty"` + URL *string `json:"url,omitempty"` + ArchiveDownloadURL *string `json:"archive_download_url,omitempty"` + Expired *bool `json:"expired,omitempty"` + CreatedAt *Timestamp `json:"created_at,omitempty"` + UpdatedAt *Timestamp `json:"updated_at,omitempty"` + ExpiresAt *Timestamp `json:"expires_at,omitempty"` + // Digest is the SHA256 digest of the artifact. + // This field will only be populated on artifacts uploaded with upload-artifact v4 or newer. + // For older versions, this field will be null. + Digest *string `json:"digest,omitempty"` + WorkflowRun *ArtifactWorkflowRun `json:"workflow_run,omitempty"` } // ArtifactList represents a list of GitHub artifacts. diff --git a/github/github-accessors.go b/github/github-accessors.go index 2dc33c6a6aa..3b728d8d922 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -934,6 +934,14 @@ func (a *Artifact) GetCreatedAt() Timestamp { return *a.CreatedAt } +// GetDigest returns the Digest field if it's non-nil, zero value otherwise. +func (a *Artifact) GetDigest() string { + if a == nil || a.Digest == nil { + return "" + } + return *a.Digest +} + // GetExpired returns the Expired field if it's non-nil, zero value otherwise. func (a *Artifact) GetExpired() bool { if a == nil || a.Expired == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 6392c967f7c..62e7fa7a43d 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -1205,6 +1205,17 @@ func TestArtifact_GetCreatedAt(tt *testing.T) { a.GetCreatedAt() } +func TestArtifact_GetDigest(tt *testing.T) { + tt.Parallel() + var zeroValue string + a := &Artifact{Digest: &zeroValue} + a.GetDigest() + a = &Artifact{} + a.GetDigest() + a = nil + a.GetDigest() +} + func TestArtifact_GetExpired(tt *testing.T) { tt.Parallel() var zeroValue bool From eeac201e21392ab1e5e8c8195eff3b7b99362cc6 Mon Sep 17 00:00:00 2001 From: Manuel Bergler Date: Thu, 10 Jul 2025 13:36:27 +0200 Subject: [PATCH 18/26] fix: Add missing `require_last_push_approval` field to branch protection rule event structs (#3623) --- github/github-accessors.go | 24 ++++++++++++++++++++++++ github/github-accessors_test.go | 30 ++++++++++++++++++++++++++++++ github/repos.go | 7 +++++++ 3 files changed, 61 insertions(+) diff --git a/github/github-accessors.go b/github/github-accessors.go index 3b728d8d922..7f6499fe23a 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -1878,6 +1878,14 @@ func (b *BranchProtectionRule) GetRequiredStatusChecksEnforcementLevel() string return *b.RequiredStatusChecksEnforcementLevel } +// GetRequireLastPushApproval returns the RequireLastPushApproval field if it's non-nil, zero value otherwise. +func (b *BranchProtectionRule) GetRequireLastPushApproval() bool { + if b == nil || b.RequireLastPushApproval == nil { + return false + } + return *b.RequireLastPushApproval +} + // GetSignatureRequirementEnforcementLevel returns the SignatureRequirementEnforcementLevel field if it's non-nil, zero value otherwise. func (b *BranchProtectionRule) GetSignatureRequirementEnforcementLevel() string { if b == nil || b.SignatureRequirementEnforcementLevel == nil { @@ -18614,6 +18622,14 @@ func (p *ProtectionChanges) GetRequiredStatusChecksEnforcementLevel() *RequiredS return p.RequiredStatusChecksEnforcementLevel } +// GetRequireLastPushApproval returns the RequireLastPushApproval field. +func (p *ProtectionChanges) GetRequireLastPushApproval() *RequireLastPushApprovalChanges { + if p == nil { + return nil + } + return p.RequireLastPushApproval +} + // GetSignatureRequirementEnforcementLevel returns the SignatureRequirementEnforcementLevel field. func (p *ProtectionChanges) GetSignatureRequirementEnforcementLevel() *SignatureRequirementEnforcementLevelChanges { if p == nil { @@ -24038,6 +24054,14 @@ func (r *RequiredStatusChecksRuleParameters) GetDoNotEnforceOnCreate() bool { return *r.DoNotEnforceOnCreate } +// GetFrom returns the From field if it's non-nil, zero value otherwise. +func (r *RequireLastPushApprovalChanges) GetFrom() bool { + if r == nil || r.From == nil { + return false + } + return *r.From +} + // GetNodeID returns the NodeID field if it's non-nil, zero value otherwise. func (r *ReviewersRequest) GetNodeID() string { if r == nil || r.NodeID == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 62e7fa7a43d..980688ae0ee 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -2467,6 +2467,17 @@ func TestBranchProtectionRule_GetRequiredStatusChecksEnforcementLevel(tt *testin b.GetRequiredStatusChecksEnforcementLevel() } +func TestBranchProtectionRule_GetRequireLastPushApproval(tt *testing.T) { + tt.Parallel() + var zeroValue bool + b := &BranchProtectionRule{RequireLastPushApproval: &zeroValue} + b.GetRequireLastPushApproval() + b = &BranchProtectionRule{} + b.GetRequireLastPushApproval() + b = nil + b.GetRequireLastPushApproval() +} + func TestBranchProtectionRule_GetSignatureRequirementEnforcementLevel(tt *testing.T) { tt.Parallel() var zeroValue string @@ -24060,6 +24071,14 @@ func TestProtectionChanges_GetRequiredStatusChecksEnforcementLevel(tt *testing.T p.GetRequiredStatusChecksEnforcementLevel() } +func TestProtectionChanges_GetRequireLastPushApproval(tt *testing.T) { + tt.Parallel() + p := &ProtectionChanges{} + p.GetRequireLastPushApproval() + p = nil + p.GetRequireLastPushApproval() +} + func TestProtectionChanges_GetSignatureRequirementEnforcementLevel(tt *testing.T) { tt.Parallel() p := &ProtectionChanges{} @@ -30909,6 +30928,17 @@ func TestRequiredStatusChecksRuleParameters_GetDoNotEnforceOnCreate(tt *testing. r.GetDoNotEnforceOnCreate() } +func TestRequireLastPushApprovalChanges_GetFrom(tt *testing.T) { + tt.Parallel() + var zeroValue bool + r := &RequireLastPushApprovalChanges{From: &zeroValue} + r.GetFrom() + r = &RequireLastPushApprovalChanges{} + r.GetFrom() + r = nil + r.GetFrom() +} + func TestReviewersRequest_GetNodeID(tt *testing.T) { tt.Parallel() var zeroValue string diff --git a/github/repos.go b/github/repos.go index e4f9cc0c074..2ce1df0596c 100644 --- a/github/repos.go +++ b/github/repos.go @@ -1074,6 +1074,7 @@ type BranchProtectionRule struct { RequiredConversationResolutionLevel *string `json:"required_conversation_resolution_level,omitempty"` AuthorizedActorsOnly *bool `json:"authorized_actors_only,omitempty"` AuthorizedActorNames []string `json:"authorized_actor_names,omitempty"` + RequireLastPushApproval *bool `json:"require_last_push_approval,omitempty"` } // ProtectionChanges represents the changes to the rule if the BranchProtection was edited. @@ -1093,6 +1094,7 @@ type ProtectionChanges struct { RequiredStatusChecks *RequiredStatusChecksChanges `json:"required_status_checks,omitempty"` RequiredStatusChecksEnforcementLevel *RequiredStatusChecksEnforcementLevelChanges `json:"required_status_checks_enforcement_level,omitempty"` SignatureRequirementEnforcementLevel *SignatureRequirementEnforcementLevelChanges `json:"signature_requirement_enforcement_level,omitempty"` + RequireLastPushApproval *RequireLastPushApprovalChanges `json:"require_last_push_approval,omitempty"` } // AdminEnforcedChanges represents the changes made to the AdminEnforced policy. @@ -1170,6 +1172,11 @@ type SignatureRequirementEnforcementLevelChanges struct { From *string `json:"from,omitempty"` } +// RequireLastPushApprovalChanges represents the changes made to the RequireLastPushApproval policy. +type RequireLastPushApprovalChanges struct { + From *bool `json:"from,omitempty"` +} + // ProtectionRequest represents a request to create/edit a branch's protection. type ProtectionRequest struct { RequiredStatusChecks *RequiredStatusChecks `json:"required_status_checks"` From ee411c1b8d2d4d9b713986d7b9a652854018a05b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Jul 2025 19:57:13 -0400 Subject: [PATCH 19/26] build(deps): bump golang.org/x/sync from 0.15.0 to 0.16.0 in /tools (#3624) --- tools/go.mod | 2 +- tools/go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/go.mod b/tools/go.mod index ad95daa30da..2ac0927482f 100644 --- a/tools/go.mod +++ b/tools/go.mod @@ -7,7 +7,7 @@ require ( github.com/getkin/kin-openapi v0.132.0 github.com/google/go-cmp v0.7.0 github.com/google/go-github/v73 v73.0.0 - golang.org/x/sync v0.15.0 + golang.org/x/sync v0.16.0 gopkg.in/yaml.v3 v3.0.1 ) diff --git a/tools/go.sum b/tools/go.sum index 951befe4893..a1ad9084d8a 100644 --- a/tools/go.sum +++ b/tools/go.sum @@ -45,8 +45,8 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0= github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= -golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8= -golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= +golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw= +golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= From 69f5bc77d40b753024a3c4410b6662cb93179bba Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Jul 2025 21:11:37 -0400 Subject: [PATCH 20/26] build(deps): bump golang.org/x/net from 0.41.0 to 0.42.0 in /scrape (#3625) --- scrape/go.mod | 2 +- scrape/go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scrape/go.mod b/scrape/go.mod index c39f77a8034..c6c25e49317 100644 --- a/scrape/go.mod +++ b/scrape/go.mod @@ -7,7 +7,7 @@ require ( github.com/google/go-cmp v0.7.0 github.com/google/go-github/v73 v73.0.0 github.com/xlzd/gotp v0.1.0 - golang.org/x/net v0.41.0 + golang.org/x/net v0.42.0 ) require ( diff --git a/scrape/go.sum b/scrape/go.sum index ae2e3715f0b..39df94d9d92 100644 --- a/scrape/go.sum +++ b/scrape/go.sum @@ -33,8 +33,8 @@ golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= -golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw= -golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA= +golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= +golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= From 18877d943620ca6045af16160b3352b2e14d446b Mon Sep 17 00:00:00 2001 From: Shunsuke Suzuki Date: Sat, 19 Jul 2025 21:17:53 +0900 Subject: [PATCH 21/26] feat: Add the `Digest` field to `ReleaseAsset` (#3628) --- github/github-accessors.go | 8 ++++++++ github/github-accessors_test.go | 11 +++++++++++ github/github-stringify_test.go | 3 ++- github/repos_releases.go | 1 + 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/github/github-accessors.go b/github/github-accessors.go index 7f6499fe23a..ad06c78c9fa 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -21062,6 +21062,14 @@ func (r *ReleaseAsset) GetCreatedAt() Timestamp { return *r.CreatedAt } +// GetDigest returns the Digest field if it's non-nil, zero value otherwise. +func (r *ReleaseAsset) GetDigest() string { + if r == nil || r.Digest == nil { + return "" + } + return *r.Digest +} + // GetDownloadCount returns the DownloadCount field if it's non-nil, zero value otherwise. func (r *ReleaseAsset) GetDownloadCount() int { if r == nil || r.DownloadCount == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 980688ae0ee..0abd03fe319 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -27138,6 +27138,17 @@ func TestReleaseAsset_GetCreatedAt(tt *testing.T) { r.GetCreatedAt() } +func TestReleaseAsset_GetDigest(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &ReleaseAsset{Digest: &zeroValue} + r.GetDigest() + r = &ReleaseAsset{} + r.GetDigest() + r = nil + r.GetDigest() +} + func TestReleaseAsset_GetDownloadCount(tt *testing.T) { tt.Parallel() var zeroValue int diff --git a/github/github-stringify_test.go b/github/github-stringify_test.go index 4563959967e..603bf87dc07 100644 --- a/github/github-stringify_test.go +++ b/github/github-stringify_test.go @@ -1661,8 +1661,9 @@ func TestReleaseAsset_String(t *testing.T) { BrowserDownloadURL: Ptr(""), Uploader: &User{}, NodeID: Ptr(""), + Digest: Ptr(""), } - want := `github.ReleaseAsset{ID:0, URL:"", Name:"", Label:"", State:"", ContentType:"", Size:0, DownloadCount:0, CreatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, UpdatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, BrowserDownloadURL:"", Uploader:github.User{}, NodeID:""}` + want := `github.ReleaseAsset{ID:0, URL:"", Name:"", Label:"", State:"", ContentType:"", Size:0, DownloadCount:0, CreatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, UpdatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, BrowserDownloadURL:"", Uploader:github.User{}, NodeID:"", Digest:""}` if got := v.String(); got != want { t.Errorf("ReleaseAsset.String = %v, want %v", got, want) } diff --git a/github/repos_releases.go b/github/repos_releases.go index d4b4591bfbb..fb90c0fd240 100644 --- a/github/repos_releases.go +++ b/github/repos_releases.go @@ -79,6 +79,7 @@ type ReleaseAsset struct { BrowserDownloadURL *string `json:"browser_download_url,omitempty"` Uploader *User `json:"uploader,omitempty"` NodeID *string `json:"node_id,omitempty"` + Digest *string `json:"digest,omitempty"` } func (r ReleaseAsset) String() string { From ff1666c9062605cb0a64d1433889c4e54eccba1f Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Sat, 19 Jul 2025 21:01:40 +0300 Subject: [PATCH 22/26] refactor: Fix revive.unnecessary-format lint issues (#3629) --- .custom-gcl.yml | 2 +- .golangci.yml | 1 + example/commitpr/main.go | 2 +- example/verifyartifact/main.go | 2 +- github/actions_artifacts_test.go | 10 +-- github/actions_cache_test.go | 14 ++-- github/actions_secrets_test.go | 4 +- github/actions_variables_test.go | 2 +- github/actions_workflow_jobs_test.go | 2 +- github/actions_workflow_runs_test.go | 4 +- github/activity_watching_test.go | 2 +- github/codespaces_secrets_test.go | 4 +- github/copilot_test.go | 8 +-- github/dependabot_secrets_test.go | 2 +- .../enterprise_network_configurations_test.go | 10 +-- github/event_test.go | 2 +- github/git_commits_test.go | 18 ++--- github/git_refs_test.go | 2 +- github/github_test.go | 68 +++++++++---------- github/issue_import_test.go | 2 +- github/issues_assignees_test.go | 2 +- github/messages_test.go | 4 +- .../orgs_codesecurity_configurations_test.go | 2 +- github/orgs_members_test.go | 4 +- github/orgs_network_configurations_test.go | 10 +-- github/orgs_outside_collaborators_test.go | 12 ++-- github/pulls_reviews_test.go | 4 +- github/repos_actions_access_test.go | 2 +- github/repos_autolinks_test.go | 4 +- github/repos_collaborators_test.go | 12 ++-- github/repos_commits_test.go | 12 ++-- github/repos_community_health_test.go | 2 +- github/repos_contents_test.go | 30 ++++---- github/repos_environments_test.go | 4 +- github/repos_invitations_test.go | 4 +- github/repos_releases_test.go | 2 +- github/repos_stats_test.go | 2 +- github/repos_test.go | 42 ++++++------ github/repos_traffic_test.go | 8 +-- github/security_advisories_test.go | 12 ++-- github/teams_discussion_comments_test.go | 2 +- github/teams_discussions_test.go | 4 +- github/teams_members_test.go | 20 +++--- github/teams_test.go | 26 +++---- github/users_followers_test.go | 2 +- github/users_test.go | 4 +- script/lint.sh | 2 +- test/integration/audit_log_test.go | 2 +- test/integration/issues_test.go | 4 +- test/integration/misc_test.go | 16 ++--- test/integration/repos_test.go | 8 +-- test/integration/users_test.go | 12 ++-- 52 files changed, 219 insertions(+), 218 deletions(-) diff --git a/.custom-gcl.yml b/.custom-gcl.yml index 53f1f717d39..0a36cedd21d 100644 --- a/.custom-gcl.yml +++ b/.custom-gcl.yml @@ -1,4 +1,4 @@ -version: v2.1.6 +version: v2.2.2 plugins: - module: "github.com/google/go-github/v68/tools/sliceofpointers" path: ./tools/sliceofpointers diff --git a/.golangci.yml b/.golangci.yml index bf47cb3b643..6ab9916cd8e 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -97,6 +97,7 @@ linters: - name: time-naming - name: unexported-naming - name: unexported-return + - name: unnecessary-format - name: unreachable-code - name: unused-parameter - name: use-any diff --git a/example/commitpr/main.go b/example/commitpr/main.go index 81eeeb3b37d..5ab545a592d 100644 --- a/example/commitpr/main.go +++ b/example/commitpr/main.go @@ -218,7 +218,7 @@ func main() { log.Fatalf("Unable to get/create the commit reference: %s\n", err) } if ref == nil { - log.Fatalf("No error where returned but the reference is nil") + log.Fatal("No error where returned but the reference is nil") } tree, err := getTree(ref) diff --git a/example/verifyartifact/main.go b/example/verifyartifact/main.go index ac80752e078..67aa8374e12 100644 --- a/example/verifyartifact/main.go +++ b/example/verifyartifact/main.go @@ -186,7 +186,7 @@ func runVerification(sev *verify.SignedEntityVerifier, pb *verify.PolicyBuilder, return err } - fmt.Fprintf(os.Stderr, "Verification successful!\n") + fmt.Fprint(os.Stderr, "Verification successful!\n") marshaled, err := json.MarshalIndent(res, "", " ") if err != nil { diff --git a/github/actions_artifacts_test.go b/github/actions_artifacts_test.go index efb84011f5d..61d74cf9b1a 100644 --- a/github/actions_artifacts_test.go +++ b/github/actions_artifacts_test.go @@ -92,7 +92,7 @@ func TestActionsService_ListArtifacts_notFound(t *testing.T) { ctx := context.Background() artifacts, resp, err := client.Actions.ListArtifacts(ctx, "o", "r", nil) if err == nil { - t.Errorf("Expected HTTP 404 response") + t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { t.Errorf("Actions.ListArtifacts return status %d, want %d", got, want) @@ -174,7 +174,7 @@ func TestActionsService_ListWorkflowRunArtifacts_notFound(t *testing.T) { ctx := context.Background() artifacts, resp, err := client.Actions.ListWorkflowRunArtifacts(ctx, "o", "r", 1, nil) if err == nil { - t.Errorf("Expected HTTP 404 response") + t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { t.Errorf("Actions.ListWorkflowRunArtifacts return status %d, want %d", got, want) @@ -261,7 +261,7 @@ func TestActionsService_GetArtifact_notFound(t *testing.T) { ctx := context.Background() artifact, resp, err := client.Actions.GetArtifact(ctx, "o", "r", 1) if err == nil { - t.Errorf("Expected HTTP 404 response") + t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { t.Errorf("Actions.GetArtifact return status %d, want %d", got, want) @@ -510,7 +510,7 @@ func TestActionsService_DownloadArtifact_unexpectedCode(t *testing.T) { ctx := context.Background() url, resp, err := client.Actions.DownloadArtifact(ctx, "o", "r", 1, 1) if err == nil { - t.Fatalf("Actions.DownloadArtifact should return error on unexpected code") + t.Fatal("Actions.DownloadArtifact should return error on unexpected code") } if !strings.Contains(err.Error(), "unexpected status code") { t.Error("Actions.DownloadArtifact should return unexpected status code") @@ -580,7 +580,7 @@ func TestActionsService_DeleteArtifact_notFound(t *testing.T) { ctx := context.Background() resp, err := client.Actions.DeleteArtifact(ctx, "o", "r", 1) if err == nil { - t.Errorf("Expected HTTP 404 response") + t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { t.Errorf("Actions.DeleteArtifact return status %d, want %d", got, want) diff --git a/github/actions_cache_test.go b/github/actions_cache_test.go index 7cad1445425..5ce1b4f9c21 100644 --- a/github/actions_cache_test.go +++ b/github/actions_cache_test.go @@ -86,7 +86,7 @@ func TestActionsService_ListCaches_notFound(t *testing.T) { ctx := context.Background() caches, resp, err := client.Actions.ListCaches(ctx, "o", "r", nil) if err == nil { - t.Errorf("Expected HTTP 404 response") + t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { t.Errorf("Actions.ListCaches return status %d, want %d", got, want) @@ -151,7 +151,7 @@ func TestActionsService_DeleteCachesByKey_notFound(t *testing.T) { ctx := context.Background() resp, err := client.Actions.DeleteCachesByKey(ctx, "o", "r", "1", Ptr("main")) if err == nil { - t.Errorf("Expected HTTP 404 response") + t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { t.Errorf("Actions.DeleteCachesByKey return status %d, want %d", got, want) @@ -213,7 +213,7 @@ func TestActionsService_DeleteCachesByID_notFound(t *testing.T) { ctx := context.Background() resp, err := client.Actions.DeleteCachesByID(ctx, "o", "r", 1) if err == nil { - t.Errorf("Expected HTTP 404 response") + t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { t.Errorf("Actions.DeleteCachesByID return status %d, want %d", got, want) @@ -291,7 +291,7 @@ func TestActionsService_GetCacheUsageForRepo_notFound(t *testing.T) { ctx := context.Background() caches, resp, err := client.Actions.GetCacheUsageForRepo(ctx, "o", "r") if err == nil { - t.Errorf("Expected HTTP 404 response") + t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { t.Errorf("Actions.GetCacheUsageForRepo return status %d, want %d", got, want) @@ -364,7 +364,7 @@ func TestActionsService_ListCacheUsageByRepoForOrg_notFound(t *testing.T) { ctx := context.Background() caches, resp, err := client.Actions.ListCacheUsageByRepoForOrg(ctx, "o", nil) if err == nil { - t.Errorf("Expected HTTP 404 response") + t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { t.Errorf("Actions.ListCacheUsageByRepoForOrg return status %d, want %d", got, want) @@ -435,7 +435,7 @@ func TestActionsService_GetCacheUsageForOrg_notFound(t *testing.T) { ctx := context.Background() caches, resp, err := client.Actions.GetTotalCacheUsageForOrg(ctx, "o") if err == nil { - t.Errorf("Expected HTTP 404 response") + t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { t.Errorf("Actions.GetTotalCacheUsageForOrg return status %d, want %d", got, want) @@ -506,7 +506,7 @@ func TestActionsService_GetCacheUsageForEnterprise_notFound(t *testing.T) { ctx := context.Background() caches, resp, err := client.Actions.GetTotalCacheUsageForEnterprise(ctx, "o") if err == nil { - t.Errorf("Expected HTTP 404 response") + t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { t.Errorf("Actions.GetTotalCacheUsageForEnterprise return status %d, want %d", got, want) diff --git a/github/actions_secrets_test.go b/github/actions_secrets_test.go index 64437260c3d..25b923c6b94 100644 --- a/github/actions_secrets_test.go +++ b/github/actions_secrets_test.go @@ -81,7 +81,7 @@ func TestPublicKey_UnmarshalJSON(t *testing.T) { pk := PublicKey{} err := json.Unmarshal(tt.data, &pk) if err == nil && tt.wantErr { - t.Errorf("PublicKey.UnmarshalJSON returned nil instead of an error") + t.Error("PublicKey.UnmarshalJSON returned nil instead of an error") } if err != nil && !tt.wantErr { t.Errorf("PublicKey.UnmarshalJSON returned an unexpected error: %+v", err) @@ -507,7 +507,7 @@ func TestActionsService_ListSelectedReposForOrgSecret(t *testing.T) { mux.HandleFunc("/orgs/o/actions/secrets/NAME/repositories", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprintf(w, `{"total_count":1,"repositories":[{"id":1}]}`) + fmt.Fprint(w, `{"total_count":1,"repositories":[{"id":1}]}`) }) opts := &ListOptions{Page: 2, PerPage: 2} diff --git a/github/actions_variables_test.go b/github/actions_variables_test.go index 83c1b8cce64..f4b0a219cdd 100644 --- a/github/actions_variables_test.go +++ b/github/actions_variables_test.go @@ -390,7 +390,7 @@ func TestActionsService_ListSelectedReposForOrgVariable(t *testing.T) { mux.HandleFunc("/orgs/o/actions/variables/NAME/repositories", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprintf(w, `{"total_count":1,"repositories":[{"id":1}]}`) + fmt.Fprint(w, `{"total_count":1,"repositories":[{"id":1}]}`) }) opts := &ListOptions{Page: 2, PerPage: 2} diff --git a/github/actions_workflow_jobs_test.go b/github/actions_workflow_jobs_test.go index 85aaa2b6bbe..5cfd6f7c0c8 100644 --- a/github/actions_workflow_jobs_test.go +++ b/github/actions_workflow_jobs_test.go @@ -368,7 +368,7 @@ func TestActionsService_GetWorkflowJobLogs_unexpectedCode(t *testing.T) { ctx := context.Background() url, resp, err := client.Actions.GetWorkflowJobLogs(ctx, "o", "r", 399444496, 1) if err == nil { - t.Fatalf("Actions.GetWorkflowJobLogs should return error on unexpected code") + t.Fatal("Actions.GetWorkflowJobLogs should return error on unexpected code") } if !strings.Contains(err.Error(), "unexpected status code") { t.Error("Actions.GetWorkflowJobLogs should return unexpected status code") diff --git a/github/actions_workflow_runs_test.go b/github/actions_workflow_runs_test.go index edba5d9c2f0..2e7eccecdc4 100644 --- a/github/actions_workflow_runs_test.go +++ b/github/actions_workflow_runs_test.go @@ -369,7 +369,7 @@ func TestActionsService_GetWorkflowRunAttemptLogs_unexpectedCode(t *testing.T) { ctx := context.Background() url, resp, err := client.Actions.GetWorkflowRunAttemptLogs(ctx, "o", "r", 399444496, 2, 1) if err == nil { - t.Fatalf("Actions.GetWorkflowRunAttemptLogs should return error on unexpected code") + t.Fatal("Actions.GetWorkflowRunAttemptLogs should return error on unexpected code") } if !strings.Contains(err.Error(), "unexpected status code") { t.Error("Actions.GetWorkflowRunAttemptLogs should return unexpected status code") @@ -680,7 +680,7 @@ func TestActionsService_GetWorkflowRunLogs_unexpectedCode(t *testing.T) { ctx := context.Background() url, resp, err := client.Actions.GetWorkflowRunLogs(ctx, "o", "r", 399444496, 1) if err == nil { - t.Fatalf("Actions.GetWorkflowRunLogs should return error on unexpected code") + t.Fatal("Actions.GetWorkflowRunLogs should return error on unexpected code") } if !strings.Contains(err.Error(), "unexpected status code") { t.Error("Actions.GetWorkflowRunLogs should return unexpected status code") diff --git a/github/activity_watching_test.go b/github/activity_watching_test.go index 8a7ab8ab71c..db014bc1f3c 100644 --- a/github/activity_watching_test.go +++ b/github/activity_watching_test.go @@ -184,7 +184,7 @@ func TestActivityService_GetRepositorySubscription_error(t *testing.T) { ctx := context.Background() _, _, err := client.Activity.GetRepositorySubscription(ctx, "o", "r") if err == nil { - t.Errorf("Expected HTTP 400 response") + t.Error("Expected HTTP 400 response") } } diff --git a/github/codespaces_secrets_test.go b/github/codespaces_secrets_test.go index 551cb1f6699..2f792bb7fae 100644 --- a/github/codespaces_secrets_test.go +++ b/github/codespaces_secrets_test.go @@ -497,7 +497,7 @@ func TestCodespacesService_ListSelectedReposForSecret(t *testing.T) { handleFunc: func(mux *http.ServeMux) { mux.HandleFunc("/user/codespaces/secrets/NAME/repositories", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprintf(w, `{"total_count":1,"repositories":[{"id":1}]}`) + fmt.Fprint(w, `{"total_count":1,"repositories":[{"id":1}]}`) }) }, call: func(ctx context.Context, client *Client) (*SelectedReposList, *Response, error) { @@ -510,7 +510,7 @@ func TestCodespacesService_ListSelectedReposForSecret(t *testing.T) { handleFunc: func(mux *http.ServeMux) { mux.HandleFunc("/orgs/o/codespaces/secrets/NAME/repositories", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprintf(w, `{"total_count":1,"repositories":[{"id":1}]}`) + fmt.Fprint(w, `{"total_count":1,"repositories":[{"id":1}]}`) }) }, call: func(ctx context.Context, client *Client) (*SelectedReposList, *Response, error) { diff --git a/github/copilot_test.go b/github/copilot_test.go index 1aeb4308555..af3e5aaa895 100644 --- a/github/copilot_test.go +++ b/github/copilot_test.go @@ -130,7 +130,7 @@ func TestCopilotSeatDetails_UnmarshalJSON(t *testing.T) { t.Parallel() err := json.Unmarshal([]byte(tc.data), seatDetails) if err == nil && tc.wantErr { - t.Errorf("CopilotSeatDetails.UnmarshalJSON returned nil instead of an error") + t.Error("CopilotSeatDetails.UnmarshalJSON returned nil instead of an error") } if err != nil && !tc.wantErr { t.Errorf("CopilotSeatDetails.UnmarshalJSON returned an unexpected error: %v", err) @@ -166,7 +166,7 @@ func TestCopilotService_GetSeatDetailsUser(t *testing.T) { if got, ok := seatDetails.GetUser(); ok && !cmp.Equal(got, want) { t.Errorf("CopilotSeatDetails.GetTeam returned %+v, want %+v", got, want) } else if !ok { - t.Errorf("CopilotSeatDetails.GetUser returned false, expected true") + t.Error("CopilotSeatDetails.GetUser returned false, expected true") } data = `{ @@ -214,7 +214,7 @@ func TestCopilotService_GetSeatDetailsTeam(t *testing.T) { if got, ok := seatDetails.GetTeam(); ok && !cmp.Equal(got, want) { t.Errorf("CopilotSeatDetails.GetTeam returned %+v, want %+v", got, want) } else if !ok { - t.Errorf("CopilotSeatDetails.GetTeam returned false, expected true") + t.Error("CopilotSeatDetails.GetTeam returned false, expected true") } data = `{ @@ -263,7 +263,7 @@ func TestCopilotService_GetSeatDetailsOrganization(t *testing.T) { if got, ok := seatDetails.GetOrganization(); ok && !cmp.Equal(got, want) { t.Errorf("CopilotSeatDetails.GetOrganization returned %+v, want %+v", got, want) } else if !ok { - t.Errorf("CopilotSeatDetails.GetOrganization returned false, expected true") + t.Error("CopilotSeatDetails.GetOrganization returned false, expected true") } data = `{ diff --git a/github/dependabot_secrets_test.go b/github/dependabot_secrets_test.go index 7b0055dc298..f4c147df55a 100644 --- a/github/dependabot_secrets_test.go +++ b/github/dependabot_secrets_test.go @@ -386,7 +386,7 @@ func TestDependabotService_ListSelectedReposForOrgSecret(t *testing.T) { mux.HandleFunc("/orgs/o/dependabot/secrets/NAME/repositories", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprintf(w, `{"total_count":1,"repositories":[{"id":1}]}`) + fmt.Fprint(w, `{"total_count":1,"repositories":[{"id":1}]}`) }) opts := &ListOptions{Page: 2, PerPage: 2} diff --git a/github/enterprise_network_configurations_test.go b/github/enterprise_network_configurations_test.go index 1c520aaff0f..b3efbd3f168 100644 --- a/github/enterprise_network_configurations_test.go +++ b/github/enterprise_network_configurations_test.go @@ -22,7 +22,7 @@ func TestEnterpriseService_ListEnterpriseNetworkConfigurations(t *testing.T) { mux.HandleFunc(" /enterprises/e/network-configurations", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"page": "3", "per_page": "2"}) - fmt.Fprintf(w, `{ + fmt.Fprint(w, `{ "total_count": 2, "network_configurations": [ { @@ -101,7 +101,7 @@ func TestEnterpriseService_CreateEnterpriseNetworkConfiguration(t *testing.T) { mux.HandleFunc("/enterprises/e/network-configurations", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") - fmt.Fprintf(w, `{ + fmt.Fprint(w, `{ "id": "123456789ABCDEF", "name": "configuration one", "compute_service": "actions", @@ -195,7 +195,7 @@ func TestEnterpriseService_GetEnterpriseNetworkConfiguration(t *testing.T) { mux.HandleFunc("/enterprises/e/network-configurations/123456789ABCDEF", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprintf(w, `{ + fmt.Fprint(w, `{ "id": "123456789ABCDEF", "name": "configuration one", "compute_service": "actions", @@ -245,7 +245,7 @@ func TestEnterpriseService_UpdateEnterpriseNetworkConfiguration(t *testing.T) { mux.HandleFunc("/enterprises/e/network-configurations/123456789ABCDEF", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PATCH") - fmt.Fprintf(w, `{ + fmt.Fprint(w, `{ "id": "123456789ABCDEF", "name": "updated configuration one", "compute_service": "none", @@ -363,7 +363,7 @@ func TestEnterpriseService_GetEnterpriseNetworkSettingsResource(t *testing.T) { mux.HandleFunc("/enterprises/e/network-settings/123456789ABCDEF", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprintf(w, `{ + fmt.Fprint(w, `{ "id": "220F78DACB92BBFBC5E6F22DE1CCF52309D", "network_configuration_id": "934E208B3EE0BD60CF5F752C426BFB53562", "name": "my_network_settings", diff --git a/github/event_test.go b/github/event_test.go index 08fc56ad063..d26f4020771 100644 --- a/github/event_test.go +++ b/github/event_test.go @@ -14,7 +14,7 @@ func TestPayload_Panic(t *testing.T) { t.Parallel() defer func() { if r := recover(); r == nil { - t.Errorf("Payload did not panic but should have") + t.Error("Payload did not panic but should have") } }() diff --git a/github/git_commits_test.go b/github/git_commits_test.go index 9fd7309a3ff..9e94624c2a0 100644 --- a/github/git_commits_test.go +++ b/github/git_commits_test.go @@ -294,7 +294,7 @@ func TestGitService_CreateSignedCommitWithInvalidParams(t *testing.T) { opts := CreateCommitOptions{Signer: uncalledSigner(t)} _, _, err := client.Git.CreateCommit(ctx, "o", "r", input, &opts) if err == nil { - t.Errorf("Expected error to be returned because invalid params were passed") + t.Error("Expected error to be returned because invalid params were passed") } } @@ -305,7 +305,7 @@ func TestGitService_CreateCommitWithNilCommit(t *testing.T) { ctx := context.Background() _, _, err := client.Git.CreateCommit(ctx, "o", "r", nil, nil) if err == nil { - t.Errorf("Expected error to be returned because commit=nil") + t.Error("Expected error to be returned because commit=nil") } } @@ -371,7 +371,7 @@ func TestGitService_createSignature_nilSigner(t *testing.T) { _, err := createSignature(nil, a) if err == nil { - t.Errorf("Expected error to be returned because no author was passed") + t.Error("Expected error to be returned because no author was passed") } } @@ -380,7 +380,7 @@ func TestGitService_createSignature_nilCommit(t *testing.T) { _, err := createSignature(uncalledSigner(t), nil) if err == nil { - t.Errorf("Expected error to be returned because no author was passed") + t.Error("Expected error to be returned because no author was passed") } } @@ -397,7 +397,7 @@ func TestGitService_createSignature_signerError(t *testing.T) { _, err := createSignature(signer, a) if err == nil { - t.Errorf("Expected error to be returned because signer returned an error") + t.Error("Expected error to be returned because signer returned an error") } } @@ -405,7 +405,7 @@ func TestGitService_createSignatureMessage_nilCommit(t *testing.T) { t.Parallel() _, err := createSignatureMessage(nil) if err == nil { - t.Errorf("Expected error to be returned due to nil key") + t.Error("Expected error to be returned due to nil key") } } @@ -423,7 +423,7 @@ func TestGitService_createSignatureMessage_nilMessage(t *testing.T) { }, }) if err == nil { - t.Errorf("Expected error to be returned due to nil key") + t.Error("Expected error to be returned due to nil key") } } @@ -441,7 +441,7 @@ func TestGitService_createSignatureMessage_emptyMessage(t *testing.T) { }, }) if err == nil { - t.Errorf("Expected error to be returned due to nil key") + t.Error("Expected error to be returned due to nil key") } } @@ -453,7 +453,7 @@ func TestGitService_createSignatureMessage_nilAuthor(t *testing.T) { Author: nil, }) if err == nil { - t.Errorf("Expected error to be returned due to nil key") + t.Error("Expected error to be returned due to nil key") } } diff --git a/github/git_refs_test.go b/github/git_refs_test.go index 0dc62b09fe7..2fb4e8f952d 100644 --- a/github/git_refs_test.go +++ b/github/git_refs_test.go @@ -85,7 +85,7 @@ func TestGitService_GetRef_noRefs(t *testing.T) { ctx := context.Background() ref, resp, err := client.Git.GetRef(ctx, "o", "r", "refs/heads/b") if err == nil { - t.Errorf("Expected HTTP 404 response") + t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { t.Errorf("Git.GetRef returned status %d, want %d", got, want) diff --git a/github/github_test.go b/github/github_test.go index 412bd26cdae..daa6d735e59 100644 --- a/github/github_test.go +++ b/github/github_test.go @@ -142,7 +142,7 @@ func testHeader(t *testing.T, r *http.Request, header string, want string) { func testURLParseError(t *testing.T, err error) { t.Helper() if err == nil { - t.Errorf("Expected error to be returned") + t.Error("Expected error to be returned") } if err, ok := err.(*url.Error); !ok || err.Op != "parse" { t.Errorf("Expected URL parse error, got %+v", err) @@ -626,7 +626,7 @@ func TestNewRequest_emptyBody(t *testing.T) { t.Fatalf("NewRequest returned unexpected error: %v", err) } if req.Body != nil { - t.Fatalf("constructed request contains a non-nil Body") + t.Fatal("constructed request contains a non-nil Body") } } @@ -647,7 +647,7 @@ func TestNewRequest_errorForNoTrailingSlash(t *testing.T) { } c.BaseURL = u if _, err := c.NewRequest(http.MethodGet, "test", nil); test.wantError && err == nil { - t.Fatalf("Expected error to be returned.") + t.Fatal("Expected error to be returned.") } else if !test.wantError && err != nil { t.Fatalf("NewRequest returned unexpected error: %v.", err) } @@ -720,7 +720,7 @@ func TestNewFormRequest_emptyBody(t *testing.T) { t.Fatalf("NewFormRequest returned unexpected error: %v", err) } if req.Body != nil { - t.Fatalf("constructed request contains a non-nil Body") + t.Fatal("constructed request contains a non-nil Body") } } @@ -741,7 +741,7 @@ func TestNewFormRequest_errorForNoTrailingSlash(t *testing.T) { } c.BaseURL = u if _, err := c.NewFormRequest("test", nil); test.wantError && err == nil { - t.Fatalf("Expected error to be returned.") + t.Fatal("Expected error to be returned.") } else if !test.wantError && err != nil { t.Fatalf("NewFormRequest returned unexpected error: %v.", err) } @@ -795,7 +795,7 @@ func TestNewUploadRequest_errorForNoTrailingSlash(t *testing.T) { } c.UploadURL = u if _, err = c.NewUploadRequest("test", nil, 0, ""); test.wantError && err == nil { - t.Fatalf("Expected error to be returned.") + t.Fatal("Expected error to be returned.") } else if !test.wantError && err != nil { t.Fatalf("NewUploadRequest returned unexpected error: %v.", err) } @@ -1081,7 +1081,7 @@ func TestDo_nilContext(t *testing.T) { _, err := client.Do(nil, req, nil) if !errors.Is(err, errNonNilContext) { - t.Errorf("Expected context must be non-nil error") + t.Error("Expected context must be non-nil error") } } @@ -1135,7 +1135,7 @@ func TestDo_preservesResponseInHTTPError(t *testing.T) { mux.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) { w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusNotFound) - fmt.Fprintf(w, `{ + fmt.Fprint(w, `{ "message": "Resource not found", "documentation_url": "https://docs.github.com/rest/reference/repos#get-a-repository" }`) @@ -1790,7 +1790,7 @@ func TestDo_rateLimit_abuseRateLimitError_retryAfter(t *testing.T) { t.Fatalf("Expected a *AbuseRateLimitError error; got %#v.", err) } if abuseRateLimitErr.RetryAfter == nil { - t.Fatalf("abuseRateLimitErr RetryAfter is nil, expected not-nil") + t.Fatal("abuseRateLimitErr RetryAfter is nil, expected not-nil") } if got, want := *abuseRateLimitErr.RetryAfter, 123*time.Second; got != want { t.Errorf("abuseRateLimitErr RetryAfter = %v, want %v", got, want) @@ -1805,7 +1805,7 @@ func TestDo_rateLimit_abuseRateLimitError_retryAfter(t *testing.T) { t.Fatalf("Expected a *AbuseRateLimitError error; got %#v.", err) } if abuseRateLimitErr.RetryAfter == nil { - t.Fatalf("abuseRateLimitErr RetryAfter is nil, expected not-nil") + t.Fatal("abuseRateLimitErr RetryAfter is nil, expected not-nil") } // the saved duration might be a bit smaller than Retry-After because the duration is calculated from the expected end-of-cooldown time if got, want := *abuseRateLimitErr.RetryAfter, 123*time.Second; want-got > 1*time.Second { @@ -1847,7 +1847,7 @@ func TestDo_rateLimit_abuseRateLimitError_xRateLimitReset(t *testing.T) { t.Fatalf("Expected a *AbuseRateLimitError error; got %#v.", err) } if abuseRateLimitErr.RetryAfter == nil { - t.Fatalf("abuseRateLimitErr RetryAfter is nil, expected not-nil") + t.Fatal("abuseRateLimitErr RetryAfter is nil, expected not-nil") } // the retry after value might be a bit smaller than the original duration because the duration is calculated from the expected end-of-cooldown time if got, want := *abuseRateLimitErr.RetryAfter, 123*time.Second; want-got > 1*time.Second { @@ -1863,7 +1863,7 @@ func TestDo_rateLimit_abuseRateLimitError_xRateLimitReset(t *testing.T) { t.Fatalf("Expected a *AbuseRateLimitError error; got %#v.", err) } if abuseRateLimitErr.RetryAfter == nil { - t.Fatalf("abuseRateLimitErr RetryAfter is nil, expected not-nil") + t.Fatal("abuseRateLimitErr RetryAfter is nil, expected not-nil") } // the saved duration might be a bit smaller than Retry-After because the duration is calculated from the expected end-of-cooldown time if got, want := *abuseRateLimitErr.RetryAfter, 123*time.Second; want-got > 1*time.Second { @@ -1907,7 +1907,7 @@ func TestDo_rateLimit_abuseRateLimitError_maxDuration(t *testing.T) { t.Fatalf("Expected a *AbuseRateLimitError error; got %#v.", err) } if abuseRateLimitErr.RetryAfter == nil { - t.Fatalf("abuseRateLimitErr RetryAfter is nil, expected not-nil") + t.Fatal("abuseRateLimitErr RetryAfter is nil, expected not-nil") } // check that the retry after is set to be the max allowed duration if got, want := *abuseRateLimitErr.RetryAfter, client.MaxSecondaryRateLimitRetryAfterDuration; got != want { @@ -2080,7 +2080,7 @@ func TestCheckResponse(t *testing.T) { err := CheckResponse(res).(*ErrorResponse) if err == nil { - t.Errorf("Expected error response.") + t.Error("Expected error response.") } want := &ErrorResponse{ @@ -2115,7 +2115,7 @@ func TestCheckResponse_RateLimit(t *testing.T) { err := CheckResponse(res).(*RateLimitError) if err == nil { - t.Errorf("Expected error response.") + t.Error("Expected error response.") } want := &RateLimitError{ @@ -2139,7 +2139,7 @@ func TestCheckResponse_AbuseRateLimit(t *testing.T) { err := CheckResponse(res).(*AbuseRateLimitError) if err == nil { - t.Errorf("Expected error response.") + t.Error("Expected error response.") } want := &AbuseRateLimitError{ @@ -2165,7 +2165,7 @@ func TestCheckResponse_RedirectionError(t *testing.T) { err := CheckResponse(res).(*RedirectionError) if err == nil { - t.Errorf("Expected error response.") + t.Error("Expected error response.") } wantedURL, parseErr := url.Parse(urlStr) @@ -2574,7 +2574,7 @@ func TestCheckResponse_noBody(t *testing.T) { err := CheckResponse(res).(*ErrorResponse) if err == nil { - t.Errorf("Expected error response.") + t.Error("Expected error response.") } want := &ErrorResponse{ @@ -2596,7 +2596,7 @@ func TestCheckResponse_unexpectedErrorStructure(t *testing.T) { err := CheckResponse(res).(*ErrorResponse) if err == nil { - t.Errorf("Expected error response.") + t.Error("Expected error response.") } want := &ErrorResponse{ @@ -2647,7 +2647,7 @@ func TestParseBooleanResponse_error(t *testing.T) { result, err := parseBoolResponse(v) if err == nil { - t.Errorf("Expected error to be returned.") + t.Error("Expected error to be returned.") } if want := false; result != want { @@ -2660,20 +2660,20 @@ func TestErrorResponse_Error(t *testing.T) { res := &http.Response{Request: &http.Request{}} err := ErrorResponse{Message: "m", Response: res} if err.Error() == "" { - t.Errorf("Expected non-empty ErrorResponse.Error()") + t.Error("Expected non-empty ErrorResponse.Error()") } // dont panic if request is nil res = &http.Response{} err = ErrorResponse{Message: "m", Response: res} if err.Error() == "" { - t.Errorf("Expected non-empty ErrorResponse.Error()") + t.Error("Expected non-empty ErrorResponse.Error()") } // dont panic if response is nil err = ErrorResponse{Message: "m"} if err.Error() == "" { - t.Errorf("Expected non-empty ErrorResponse.Error()") + t.Error("Expected non-empty ErrorResponse.Error()") } } @@ -2681,7 +2681,7 @@ func TestError_Error(t *testing.T) { t.Parallel() err := Error{} if err.Error() == "" { - t.Errorf("Expected non-empty Error.Error()") + t.Error("Expected non-empty Error.Error()") } } @@ -2693,7 +2693,7 @@ func TestSetCredentialsAsHeaders(t *testing.T) { actualID, actualSecret, ok := modifiedRequest.BasicAuth() if !ok { - t.Errorf("request does not contain basic credentials") + t.Error("request does not contain basic credentials") } if actualID != id { @@ -2713,7 +2713,7 @@ func TestUnauthenticatedRateLimitedTransport(t *testing.T) { mux.HandleFunc("/", func(_ http.ResponseWriter, r *http.Request) { id, secret, ok := r.BasicAuth() if !ok { - t.Errorf("request does not contain basic auth credentials") + t.Error("request does not contain basic auth credentials") } if id != clientID { t.Errorf("request contained basic auth username %q, want %q", id, clientID) @@ -2743,7 +2743,7 @@ func TestUnauthenticatedRateLimitedTransport_missingFields(t *testing.T) { } _, err := tp.RoundTrip(nil) if err == nil { - t.Errorf("Expected error to be returned") + t.Error("Expected error to be returned") } // missing ClientSecret @@ -2752,7 +2752,7 @@ func TestUnauthenticatedRateLimitedTransport_missingFields(t *testing.T) { } _, err = tp.RoundTrip(nil) if err == nil { - t.Errorf("Expected error to be returned") + t.Error("Expected error to be returned") } } @@ -2764,7 +2764,7 @@ func TestUnauthenticatedRateLimitedTransport_transport(t *testing.T) { ClientSecret: "secret", } if tp.transport() != http.DefaultTransport { - t.Errorf("Expected http.DefaultTransport to be used.") + t.Error("Expected http.DefaultTransport to be used.") } // custom transport @@ -2774,7 +2774,7 @@ func TestUnauthenticatedRateLimitedTransport_transport(t *testing.T) { Transport: &http.Transport{}, } if tp.transport() == http.DefaultTransport { - t.Errorf("Expected custom transport to be used.") + t.Error("Expected custom transport to be used.") } } @@ -2787,7 +2787,7 @@ func TestBasicAuthTransport(t *testing.T) { mux.HandleFunc("/", func(_ http.ResponseWriter, r *http.Request) { u, p, ok := r.BasicAuth() if !ok { - t.Errorf("request does not contain basic auth credentials") + t.Error("request does not contain basic auth credentials") } if u != username { t.Errorf("request contained basic auth username %q, want %q", u, username) @@ -2818,7 +2818,7 @@ func TestBasicAuthTransport_transport(t *testing.T) { // default transport tp := &BasicAuthTransport{} if tp.transport() != http.DefaultTransport { - t.Errorf("Expected http.DefaultTransport to be used.") + t.Error("Expected http.DefaultTransport to be used.") } // custom transport @@ -2826,7 +2826,7 @@ func TestBasicAuthTransport_transport(t *testing.T) { Transport: &http.Transport{}, } if tp.transport() == http.DefaultTransport { - t.Errorf("Expected custom transport to be used.") + t.Error("Expected custom transport to be used.") } } @@ -3223,7 +3223,7 @@ func TestDeploymentProtectionRuleEvent_GetRunID(t *testing.T) { url = "https://api.github.com/repos/dummy-org/dummy-repo/actions/runs/abc123/deployment_protection_rule" got, err := e.GetRunID() if err == nil { - t.Errorf("Expected error to be returned") + t.Error("Expected error to be returned") } if got != want { diff --git a/github/issue_import_test.go b/github/issue_import_test.go index fd081d0d233..4694df7c336 100644 --- a/github/issue_import_test.go +++ b/github/issue_import_test.go @@ -266,7 +266,7 @@ func TestIssueImportService_CheckStatusSince_badResponse(t *testing.T) { ctx := context.Background() if _, _, err := client.IssueImport.CheckStatusSince(ctx, "o", "r", Timestamp{time.Now()}); err == nil { - t.Errorf("CheckStatusSince returned no error, want JSON err") + t.Error("CheckStatusSince returned no error, want JSON err") } } diff --git a/github/issues_assignees_test.go b/github/issues_assignees_test.go index 06c91a07966..3ca05418d99 100644 --- a/github/issues_assignees_test.go +++ b/github/issues_assignees_test.go @@ -138,7 +138,7 @@ func TestIssuesService_IsAssignee_error(t *testing.T) { ctx := context.Background() assignee, _, err := client.Issues.IsAssignee(ctx, "o", "r", "u") if err == nil { - t.Errorf("Expected HTTP 400 response") + t.Error("Expected HTTP 400 response") } if want := false; assignee != want { t.Errorf("Issues.IsAssignee returned %+v, want %+v", assignee, want) diff --git a/github/messages_test.go b/github/messages_test.go index b414a9e6a93..8ba48808848 100644 --- a/github/messages_test.go +++ b/github/messages_test.go @@ -589,14 +589,14 @@ func TestParseWebHook_BadMessageType(t *testing.T) { func TestValidatePayloadFromBody_UnableToParseBody(t *testing.T) { t.Parallel() if _, err := ValidatePayloadFromBody("application/x-www-form-urlencoded", bytes.NewReader([]byte(`%`)), "sha1=", []byte{}); err == nil { - t.Errorf("ValidatePayloadFromBody returned nil; wanted error") + t.Error("ValidatePayloadFromBody returned nil; wanted error") } } func TestValidatePayloadFromBody_UnsupportedContentType(t *testing.T) { t.Parallel() if _, err := ValidatePayloadFromBody("invalid", bytes.NewReader([]byte(`{}`)), "sha1=", []byte{}); err == nil { - t.Errorf("ValidatePayloadFromBody returned nil; wanted error") + t.Error("ValidatePayloadFromBody returned nil; wanted error") } } diff --git a/github/orgs_codesecurity_configurations_test.go b/github/orgs_codesecurity_configurations_test.go index f2a35c2c3cd..188e31fbcfc 100644 --- a/github/orgs_codesecurity_configurations_test.go +++ b/github/orgs_codesecurity_configurations_test.go @@ -362,7 +362,7 @@ func TestOrganizationsService_SetDefaultCodeSecurityConfiguration(t *testing.T) mux.HandleFunc("/orgs/o/code-security/configurations/1/defaults", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") - fmt.Fprintf(w, ` + fmt.Fprint(w, ` { "default_for_new_repos": "all", "configuration": diff --git a/github/orgs_members_test.go b/github/orgs_members_test.go index dbdb0f284a1..28040fc9c19 100644 --- a/github/orgs_members_test.go +++ b/github/orgs_members_test.go @@ -160,7 +160,7 @@ func TestOrganizationsService_IsMember_error(t *testing.T) { ctx := context.Background() member, _, err := client.Organizations.IsMember(ctx, "o", "u") if err == nil { - t.Errorf("Expected HTTP 400 response") + t.Error("Expected HTTP 400 response") } if want := false; member != want { t.Errorf("Organizations.IsMember returned %+v, want %+v", member, want) @@ -243,7 +243,7 @@ func TestOrganizationsService_IsPublicMember_error(t *testing.T) { ctx := context.Background() member, _, err := client.Organizations.IsPublicMember(ctx, "o", "u") if err == nil { - t.Errorf("Expected HTTP 400 response") + t.Error("Expected HTTP 400 response") } if want := false; member != want { t.Errorf("Organizations.IsPublicMember returned %+v, want %+v", member, want) diff --git a/github/orgs_network_configurations_test.go b/github/orgs_network_configurations_test.go index 9a095066990..ebfca42d878 100644 --- a/github/orgs_network_configurations_test.go +++ b/github/orgs_network_configurations_test.go @@ -22,7 +22,7 @@ func TestOrganizationsService_ListOrgsNetworkConfigurations(t *testing.T) { mux.HandleFunc("/orgs/o/settings/network-configurations", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"page": "1", "per_page": "3"}) - fmt.Fprintf(w, `{ + fmt.Fprint(w, `{ "total_count": 3, "network_configurations": [ { @@ -126,7 +126,7 @@ func TestOrganizationsService_CreateOrgsNetworkConfiguration(t *testing.T) { mux.HandleFunc("/orgs/o/settings/network-configurations", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") - fmt.Fprintf(w, `{ + fmt.Fprint(w, `{ "id": "456789ABDCEF123", "name": "network-configuration-two", "compute_service": "none", @@ -246,7 +246,7 @@ func TestOrganizationsService_GetOrgsNetworkConfiguration(t *testing.T) { mux.HandleFunc("/orgs/o/settings/network-configurations/789ABDCEF123456", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprintf(w, `{ + fmt.Fprint(w, `{ "id": "789ABDCEF123456", "name": "Network Configuration Three", "compute_service": "codespaces", @@ -299,7 +299,7 @@ func TestOrganizationsService_UpdateOrgsNetworkConfiguration(t *testing.T) { mux.HandleFunc("/orgs/o/settings/network-configurations/789ABDCEF123456", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PATCH") - fmt.Fprintf(w, `{ + fmt.Fprint(w, `{ "id": "789ABDCEF123456", "name": "Network Configuration Three Update", "compute_service": "actions", @@ -444,7 +444,7 @@ func TestOrganizationsService_GetOrgsNetworkConfigurationResource(t *testing.T) mux.HandleFunc("/orgs/o/settings/network-settings/789ABDCEF123456", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprintf(w, `{ + fmt.Fprint(w, `{ "id": "220F78DACB92BBFBC5E6F22DE1CCF52309D", "network_configuration_id": "934E208B3EE0BD60CF5F752C426BFB53562", "name": "my_network_settings", diff --git a/github/orgs_outside_collaborators_test.go b/github/orgs_outside_collaborators_test.go index 7120449c02f..7dd5618f697 100644 --- a/github/orgs_outside_collaborators_test.go +++ b/github/orgs_outside_collaborators_test.go @@ -105,9 +105,9 @@ func TestOrganizationsService_RemoveOutsideCollaborator_NonMember(t *testing.T) ctx := context.Background() _, err := client.Organizations.RemoveOutsideCollaborator(ctx, "o", "u") if err, ok := err.(*ErrorResponse); !ok { - t.Errorf("Organizations.RemoveOutsideCollaborator did not return an error") + t.Error("Organizations.RemoveOutsideCollaborator did not return an error") } else if err.Response.StatusCode != http.StatusNotFound { - t.Errorf("Organizations.RemoveOutsideCollaborator did not return 404 status code") + t.Error("Organizations.RemoveOutsideCollaborator did not return 404 status code") } } @@ -124,9 +124,9 @@ func TestOrganizationsService_RemoveOutsideCollaborator_Member(t *testing.T) { ctx := context.Background() _, err := client.Organizations.RemoveOutsideCollaborator(ctx, "o", "u") if err, ok := err.(*ErrorResponse); !ok { - t.Errorf("Organizations.RemoveOutsideCollaborator did not return an error") + t.Error("Organizations.RemoveOutsideCollaborator did not return an error") } else if err.Response.StatusCode != http.StatusUnprocessableEntity { - t.Errorf("Organizations.RemoveOutsideCollaborator did not return 422 status code") + t.Error("Organizations.RemoveOutsideCollaborator did not return 422 status code") } } @@ -169,8 +169,8 @@ func TestOrganizationsService_ConvertMemberToOutsideCollaborator_NonMemberOrLast ctx := context.Background() _, err := client.Organizations.ConvertMemberToOutsideCollaborator(ctx, "o", "u") if err, ok := err.(*ErrorResponse); !ok { - t.Errorf("Organizations.ConvertMemberToOutsideCollaborator did not return an error") + t.Error("Organizations.ConvertMemberToOutsideCollaborator did not return an error") } else if err.Response.StatusCode != http.StatusForbidden { - t.Errorf("Organizations.ConvertMemberToOutsideCollaborator did not return 403 status code") + t.Error("Organizations.ConvertMemberToOutsideCollaborator did not return 403 status code") } } diff --git a/github/pulls_reviews_test.go b/github/pulls_reviews_test.go index 4df4d74f144..44df29f506d 100644 --- a/github/pulls_reviews_test.go +++ b/github/pulls_reviews_test.go @@ -437,7 +437,7 @@ func TestPullRequestsService_CreateReview_badReview(t *testing.T) { _, _, err := client.PullRequests.CreateReview(ctx, "o", "r", 1, badReview) if err == nil { - t.Errorf("CreateReview badReview err = nil, want err") + t.Error("CreateReview badReview err = nil, want err") } } @@ -494,7 +494,7 @@ func TestPullRequestsService_UpdateReview(t *testing.T) { mux.HandleFunc("/repos/o/r/pulls/1/reviews/1", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") - fmt.Fprintf(w, `{"id":1}`) + fmt.Fprint(w, `{"id":1}`) }) ctx := context.Background() diff --git a/github/repos_actions_access_test.go b/github/repos_actions_access_test.go index f732bd35cb5..5efab0c044b 100644 --- a/github/repos_actions_access_test.go +++ b/github/repos_actions_access_test.go @@ -21,7 +21,7 @@ func TestRepositoriesService_GetActionsAccessLevel(t *testing.T) { mux.HandleFunc("/repos/o/r/actions/permissions/access", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprintf(w, `{"access_level": "none"}`) + fmt.Fprint(w, `{"access_level": "none"}`) }) ctx := context.Background() diff --git a/github/repos_autolinks_test.go b/github/repos_autolinks_test.go index 5fdd8d44f0b..12e7333a1b6 100644 --- a/github/repos_autolinks_test.go +++ b/github/repos_autolinks_test.go @@ -22,7 +22,7 @@ func TestRepositoriesService_ListAutolinks(t *testing.T) { mux.HandleFunc("/repos/o/r/autolinks", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"page": "2"}) - fmt.Fprintf(w, `[{"id":1, "key_prefix": "TICKET-", "url_template": "https://example.com/TICKET?query="}, {"id":2, "key_prefix": "STORY-", "url_template": "https://example.com/STORY?query="}]`) + fmt.Fprint(w, `[{"id":1, "key_prefix": "TICKET-", "url_template": "https://example.com/TICKET?query="}, {"id":2, "key_prefix": "STORY-", "url_template": "https://example.com/STORY?query="}]`) }) opt := &ListOptions{ @@ -119,7 +119,7 @@ func TestRepositoriesService_GetAutolink(t *testing.T) { mux.HandleFunc("/repos/o/r/autolinks/1", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprintf(w, `{"id":1, "key_prefix": "TICKET-", "url_template": "https://example.com/TICKET?query="}`) + fmt.Fprint(w, `{"id":1, "key_prefix": "TICKET-", "url_template": "https://example.com/TICKET?query="}`) }) ctx := context.Background() diff --git a/github/repos_collaborators_test.go b/github/repos_collaborators_test.go index 0525ca5f568..b91b0932978 100644 --- a/github/repos_collaborators_test.go +++ b/github/repos_collaborators_test.go @@ -22,7 +22,7 @@ func TestRepositoriesService_ListCollaborators(t *testing.T) { mux.HandleFunc("/repos/o/r/collaborators", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"page": "2"}) - fmt.Fprintf(w, `[{"id":1}, {"id":2}]`) + fmt.Fprint(w, `[{"id":1}, {"id":2}]`) }) opt := &ListCollaboratorsOptions{ @@ -61,7 +61,7 @@ func TestRepositoriesService_ListCollaborators_withAffiliation(t *testing.T) { mux.HandleFunc("/repos/o/r/collaborators", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"affiliation": "all", "page": "2"}) - fmt.Fprintf(w, `[{"id":1}, {"id":2}]`) + fmt.Fprint(w, `[{"id":1}, {"id":2}]`) }) opt := &ListCollaboratorsOptions{ @@ -101,7 +101,7 @@ func TestRepositoriesService_ListCollaborators_withPermission(t *testing.T) { mux.HandleFunc("/repos/o/r/collaborators", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"permission": "pull", "page": "2"}) - fmt.Fprintf(w, `[{"id":1}, {"id":2}]`) + fmt.Fprint(w, `[{"id":1}, {"id":2}]`) }) opt := &ListCollaboratorsOptions{ @@ -159,7 +159,7 @@ func TestRepositoriesService_IsCollaborator_True(t *testing.T) { } if !isCollab { - t.Errorf("Repositories.IsCollaborator returned false, want true") + t.Error("Repositories.IsCollaborator returned false, want true") } const methodName = "IsCollaborator" @@ -193,7 +193,7 @@ func TestRepositoriesService_IsCollaborator_False(t *testing.T) { } if isCollab { - t.Errorf("Repositories.IsCollaborator returned true, want false") + t.Error("Repositories.IsCollaborator returned true, want false") } const methodName = "IsCollaborator" @@ -226,7 +226,7 @@ func TestRepositoryService_GetPermissionLevel(t *testing.T) { mux.HandleFunc("/repos/o/r/collaborators/u/permission", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprintf(w, `{"permission":"admin","user":{"login":"u"}}`) + fmt.Fprint(w, `{"permission":"admin","user":{"login":"u"}}`) }) ctx := context.Background() diff --git a/github/repos_commits_test.go b/github/repos_commits_test.go index 28b8821ba98..103f00e780e 100644 --- a/github/repos_commits_test.go +++ b/github/repos_commits_test.go @@ -32,7 +32,7 @@ func TestRepositoriesService_ListCommits(t *testing.T) { "since": "2013-08-01T00:00:00Z", "until": "2013-09-03T00:00:00Z", }) - fmt.Fprintf(w, `[{"sha": "s"}]`) + fmt.Fprint(w, `[{"sha": "s"}]`) }) opt := &CommitsListOptions{ @@ -75,7 +75,7 @@ func TestRepositoriesService_GetCommit(t *testing.T) { mux.HandleFunc("/repos/o/r/commits/s", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"per_page": "2", "page": "2"}) - fmt.Fprintf(w, `{ + fmt.Fprint(w, `{ "sha": "s", "commit": { "message": "m" }, "author": { "login": "l" }, @@ -267,7 +267,7 @@ func TestRepositoriesService_GetCommitSHA1(t *testing.T) { got, _, err = client.Repositories.GetCommitSHA1(ctx, "o", "r", "tag", sha1) if err == nil { - t.Errorf("Expected HTTP 304 response") + t.Error("Expected HTTP 304 response") } want = "" @@ -323,7 +323,7 @@ func TestRepositoriesService_NonAlphabetCharacter_GetCommitSHA1(t *testing.T) { got, _, err = client.Repositories.GetCommitSHA1(ctx, "o", "r", "tag", sha1) if err == nil { - t.Errorf("Expected HTTP 304 response") + t.Error("Expected HTTP 304 response") } if want := ""; got != want { @@ -364,7 +364,7 @@ func TestRepositoriesService_TrailingPercent_GetCommitSHA1(t *testing.T) { got, _, err = client.Repositories.GetCommitSHA1(ctx, "o", "r", "tag", sha1) if err == nil { - t.Errorf("Expected HTTP 304 response") + t.Error("Expected HTTP 304 response") } if want := ""; got != want { @@ -649,7 +649,7 @@ func TestRepositoriesService_ListBranchesHeadCommit(t *testing.T) { mux.HandleFunc("/repos/o/r/commits/s/branches-where-head", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprintf(w, `[{"name": "b","commit":{"sha":"2e90302801c870f17b6152327d9b9a03c8eca0e2","url":"https://api.github.com/repos/google/go-github/commits/2e90302801c870f17b6152327d9b9a03c8eca0e2"},"protected":true}]`) + fmt.Fprint(w, `[{"name": "b","commit":{"sha":"2e90302801c870f17b6152327d9b9a03c8eca0e2","url":"https://api.github.com/repos/google/go-github/commits/2e90302801c870f17b6152327d9b9a03c8eca0e2"},"protected":true}]`) }) ctx := context.Background() diff --git a/github/repos_community_health_test.go b/github/repos_community_health_test.go index eb7f2ce507c..5cd3c1587f3 100644 --- a/github/repos_community_health_test.go +++ b/github/repos_community_health_test.go @@ -21,7 +21,7 @@ func TestRepositoriesService_GetCommunityHealthMetrics(t *testing.T) { mux.HandleFunc("/repos/o/r/community/profile", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprintf(w, `{ + fmt.Fprint(w, `{ "health_percentage": 100, "description": "My first repository on GitHub!", "documentation": null, diff --git a/github/repos_contents_test.go b/github/repos_contents_test.go index e698cc8f528..0c088e2bdc0 100644 --- a/github/repos_contents_test.go +++ b/github/repos_contents_test.go @@ -305,15 +305,15 @@ func TestRepositoriesService_DownloadContents_NoDownloadURL(t *testing.T) { ctx := context.Background() reader, resp, err := client.Repositories.DownloadContents(ctx, "o", "r", "d/f", nil) if err == nil { - t.Errorf("Repositories.DownloadContents did not return expected error") + t.Error("Repositories.DownloadContents did not return expected error") } if resp == nil { - t.Errorf("Repositories.DownloadContents did not return expected response") + t.Error("Repositories.DownloadContents did not return expected response") } if reader != nil { - t.Errorf("Repositories.DownloadContents did not return expected reader") + t.Error("Repositories.DownloadContents did not return expected reader") } } @@ -338,15 +338,15 @@ func TestRepositoriesService_DownloadContents_NoFile(t *testing.T) { ctx := context.Background() reader, resp, err := client.Repositories.DownloadContents(ctx, "o", "r", "d/f", nil) if err == nil { - t.Errorf("Repositories.DownloadContents did not return expected error") + t.Error("Repositories.DownloadContents did not return expected error") } if resp == nil { - t.Errorf("Repositories.DownloadContents did not return expected response") + t.Error("Repositories.DownloadContents did not return expected response") } if reader != nil { - t.Errorf("Repositories.DownloadContents did not return expected reader") + t.Error("Repositories.DownloadContents did not return expected reader") } } @@ -389,7 +389,7 @@ func TestRepositoriesService_DownloadContentsWithMeta_SuccessForFile(t *testing. t.Errorf("Repositories.DownloadContentsWithMeta returned content name %v, want %v", got, want) } } else { - t.Errorf("Returned RepositoryContent is null") + t.Error("Returned RepositoryContent is null") } const methodName = "DownloadContentsWithMeta" @@ -452,7 +452,7 @@ func TestRepositoriesService_DownloadContentsWithMeta_SuccessForDirectory(t *tes t.Errorf("Repositories.DownloadContentsWithMeta returned content name %v, want %v", got, want) } } else { - t.Errorf("Returned RepositoryContent is null") + t.Error("Returned RepositoryContent is null") } } @@ -509,7 +509,7 @@ func TestRepositoriesService_DownloadContentsWithMeta_FailedResponse(t *testing. t.Errorf("Repositories.DownloadContentsWithMeta returned content name %v, want %v", got, want) } } else { - t.Errorf("Returned RepositoryContent is null") + t.Error("Returned RepositoryContent is null") } } @@ -536,19 +536,19 @@ func TestRepositoriesService_DownloadContentsWithMeta_NoDownloadURL(t *testing.T ctx := context.Background() reader, contents, resp, err := client.Repositories.DownloadContentsWithMeta(ctx, "o", "r", "d/f", nil) if err == nil { - t.Errorf("Repositories.DownloadContentsWithMeta did not return expected error") + t.Error("Repositories.DownloadContentsWithMeta did not return expected error") } if reader != nil { - t.Errorf("Repositories.DownloadContentsWithMeta did not return expected reader") + t.Error("Repositories.DownloadContentsWithMeta did not return expected reader") } if resp == nil { - t.Errorf("Repositories.DownloadContentsWithMeta did not return expected response") + t.Error("Repositories.DownloadContentsWithMeta did not return expected response") } if contents == nil { - t.Errorf("Repositories.DownloadContentsWithMeta did not return expected content") + t.Error("Repositories.DownloadContentsWithMeta did not return expected content") } } @@ -564,11 +564,11 @@ func TestRepositoriesService_DownloadContentsWithMeta_NoFile(t *testing.T) { ctx := context.Background() _, _, resp, err := client.Repositories.DownloadContentsWithMeta(ctx, "o", "r", "d/f", nil) if err == nil { - t.Errorf("Repositories.DownloadContentsWithMeta did not return expected error") + t.Error("Repositories.DownloadContentsWithMeta did not return expected error") } if resp == nil { - t.Errorf("Repositories.DownloadContentsWithMeta did not return expected response") + t.Error("Repositories.DownloadContentsWithMeta did not return expected response") } } diff --git a/github/repos_environments_test.go b/github/repos_environments_test.go index 73c5cb736d9..463742fc97f 100644 --- a/github/repos_environments_test.go +++ b/github/repos_environments_test.go @@ -75,10 +75,10 @@ func TestRequiredReviewer_UnmarshalJSON(t *testing.T) { rule := []*RequiredReviewer{} err := json.Unmarshal(test.data, &rule) if err != nil && !test.wantError { - t.Errorf("RequiredReviewer.UnmarshalJSON returned an error when we expected nil") + t.Error("RequiredReviewer.UnmarshalJSON returned an error when we expected nil") } if err == nil && test.wantError { - t.Errorf("RequiredReviewer.UnmarshalJSON returned no error when we expected one") + t.Error("RequiredReviewer.UnmarshalJSON returned no error when we expected one") } if !cmp.Equal(test.wantRule, rule) { t.Errorf("RequiredReviewer.UnmarshalJSON expected rule %+v, got %+v", test.wantRule, rule) diff --git a/github/repos_invitations_test.go b/github/repos_invitations_test.go index 06ca3e8bed7..ca26ba7f8c4 100644 --- a/github/repos_invitations_test.go +++ b/github/repos_invitations_test.go @@ -21,7 +21,7 @@ func TestRepositoriesService_ListInvitations(t *testing.T) { mux.HandleFunc("/repos/o/r/invitations", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testFormValues(t, r, values{"page": "2"}) - fmt.Fprintf(w, `[{"id":1}, {"id":2}]`) + fmt.Fprint(w, `[{"id":1}, {"id":2}]`) }) opt := &ListOptions{Page: 2} @@ -83,7 +83,7 @@ func TestRepositoriesService_UpdateInvitation(t *testing.T) { mux.HandleFunc("/repos/o/r/invitations/2", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PATCH") - fmt.Fprintf(w, `{"id":1}`) + fmt.Fprint(w, `{"id":1}`) }) ctx := context.Background() diff --git a/github/repos_releases_test.go b/github/repos_releases_test.go index 4e777228ad2..95d1c33e33a 100644 --- a/github/repos_releases_test.go +++ b/github/repos_releases_test.go @@ -745,7 +745,7 @@ func TestRepositoriesService_UploadReleaseAsset(t *testing.T) { testFormValues(t, r, test.expectedFormValues) testBody(t, r, "Upload me !\n") - fmt.Fprintf(w, `{"id":1}`) + fmt.Fprint(w, `{"id":1}`) }) file := openTestFile(t, test.fileName, "Upload me !\n") diff --git a/github/repos_stats_test.go b/github/repos_stats_test.go index 358e2705bab..467ef1693c5 100644 --- a/github/repos_stats_test.go +++ b/github/repos_stats_test.go @@ -302,7 +302,7 @@ func TestRepositoriesService_AcceptedError(t *testing.T) { ctx := context.Background() stats, _, err := client.Repositories.ListContributorsStats(ctx, "o", "r") if err == nil { - t.Errorf("RepositoriesService.AcceptedError should have returned an error") + t.Error("RepositoriesService.AcceptedError should have returned an error") } if _, ok := err.(*AcceptedError); !ok { diff --git a/github/repos_test.go b/github/repos_test.go index 668baecf5f7..0493484d9c0 100644 --- a/github/repos_test.go +++ b/github/repos_test.go @@ -676,7 +676,7 @@ func TestRepositoriesService_GetAutomatedSecurityFixes(t *testing.T) { ctx := context.Background() fixes, _, err := client.Repositories.GetAutomatedSecurityFixes(ctx, "o", "r") if err != nil { - t.Errorf("Repositories.GetAutomatedSecurityFixes returned error: #{err}") + t.Errorf("Repositories.GetAutomatedSecurityFixes returned error: %v", err) } want := &AutomatedSecurityFixes{ @@ -684,7 +684,7 @@ func TestRepositoriesService_GetAutomatedSecurityFixes(t *testing.T) { Paused: Ptr(false), } if !cmp.Equal(fixes, want) { - t.Errorf("Repositories.GetAutomatedSecurityFixes returned #{fixes}, want #{want}") + t.Errorf("Repositories.GetAutomatedSecurityFixes returned %#v, want %#v", fixes, want) } const methodName = "GetAutomatedSecurityFixes" @@ -1410,7 +1410,7 @@ func TestRepositoriesService_GetBranchProtection_branchNotProtected(t *testing.T protection, _, err := client.Repositories.GetBranchProtection(ctx, "o", "r", test.branch) if protection != nil { - t.Errorf("Repositories.GetBranchProtection returned non-nil protection data") + t.Error("Repositories.GetBranchProtection returned non-nil protection data") } if err != ErrBranchNotProtected { @@ -1474,7 +1474,7 @@ func TestRepositoriesService_UpdateBranchProtection_Contexts(t *testing.T) { // TODO: remove custom Accept header when this API fully launches testHeader(t, r, "Accept", mediaTypeRequiredApprovingReviewsPreview) - fmt.Fprintf(w, `{ + fmt.Fprint(w, `{ "required_status_checks":{ "strict":true, "contexts":["continuous-integration"], @@ -1663,7 +1663,7 @@ func TestRepositoriesService_UpdateBranchProtection_EmptyContexts(t *testing.T) // TODO: remove custom Accept header when this API fully launches testHeader(t, r, "Accept", mediaTypeRequiredApprovingReviewsPreview) - fmt.Fprintf(w, `{ + fmt.Fprint(w, `{ "required_status_checks":{ "strict":true, "contexts":[], @@ -1843,7 +1843,7 @@ func TestRepositoriesService_UpdateBranchProtection_Checks(t *testing.T) { // TODO: remove custom Accept header when this API fully launches testHeader(t, r, "Accept", mediaTypeRequiredApprovingReviewsPreview) - fmt.Fprintf(w, `{ + fmt.Fprint(w, `{ "required_status_checks":{ "strict":true, "contexts":["continuous-integration"], @@ -1997,7 +1997,7 @@ func TestRepositoriesService_UpdateBranchProtection_EmptyChecks(t *testing.T) { // TODO: remove custom Accept header when this API fully launches testHeader(t, r, "Accept", mediaTypeRequiredApprovingReviewsPreview) - fmt.Fprintf(w, `{ + fmt.Fprint(w, `{ "required_status_checks":{ "strict":true, "contexts":null, @@ -2140,7 +2140,7 @@ func TestRepositoriesService_UpdateBranchProtection_StrictNoChecks(t *testing.T) // TODO: remove custom Accept header when this API fully launches testHeader(t, r, "Accept", mediaTypeRequiredApprovingReviewsPreview) - fmt.Fprintf(w, `{ + fmt.Fprint(w, `{ "required_status_checks":{ "strict":true, "contexts":[] @@ -2263,7 +2263,7 @@ func TestRepositoriesService_UpdateBranchProtection_RequireLastPushApproval(t *t t.Errorf("Request body = %+v, want %+v", v, input) } - fmt.Fprintf(w, `{ + fmt.Fprint(w, `{ "required_pull_request_reviews":{ "require_last_push_approval":true } @@ -2490,7 +2490,7 @@ func TestRepositoriesService_GetRequiredStatusChecks_branchNotProtected(t *testi checks, _, err := client.Repositories.GetRequiredStatusChecks(ctx, "o", "r", test.branch) if checks != nil { - t.Errorf("Repositories.GetRequiredStatusChecks returned non-nil status-checks data") + t.Error("Repositories.GetRequiredStatusChecks returned non-nil status-checks data") } if err != ErrBranchNotProtected { @@ -2529,7 +2529,7 @@ func TestRepositoriesService_UpdateRequiredStatusChecks_Contexts(t *testing.T) { t.Errorf("Request body = %+v, want %+v", v, input) } testHeader(t, r, "Accept", mediaTypeV3) - fmt.Fprintf(w, `{ + fmt.Fprint(w, `{ "strict":true, "contexts":["continuous-integration"], "checks": [ @@ -2620,7 +2620,7 @@ func TestRepositoriesService_UpdateRequiredStatusChecks_Checks(t *testing.T) { t.Errorf("Request body = %+v, want %+v", v, input) } testHeader(t, r, "Accept", mediaTypeV3) - fmt.Fprintf(w, `{ + fmt.Fprint(w, `{ "strict":true, "contexts":["continuous-integration"], "checks": [ @@ -2786,7 +2786,7 @@ func TestRepositoriesService_ListRequiredStatusChecksContexts_branchNotProtected contexts, _, err := client.Repositories.ListRequiredStatusChecksContexts(ctx, "o", "r", test.branch) if contexts != nil { - t.Errorf("Repositories.ListRequiredStatusChecksContexts returned non-nil contexts data") + t.Error("Repositories.ListRequiredStatusChecksContexts returned non-nil contexts data") } if err != ErrBranchNotProtected { @@ -2815,7 +2815,7 @@ func TestRepositoriesService_GetPullRequestReviewEnforcement(t *testing.T) { testMethod(t, r, "GET") // TODO: remove custom Accept header when this API fully launches testHeader(t, r, "Accept", mediaTypeRequiredApprovingReviewsPreview) - fmt.Fprintf(w, `{ + fmt.Fprint(w, `{ "dismissal_restrictions":{ "users":[{"id":1,"login":"u"}], "teams":[{"id":2,"slug":"t"}], @@ -2904,7 +2904,7 @@ func TestRepositoriesService_UpdatePullRequestReviewEnforcement(t *testing.T) { } // TODO: remove custom Accept header when this API fully launches testHeader(t, r, "Accept", mediaTypeRequiredApprovingReviewsPreview) - fmt.Fprintf(w, `{ + fmt.Fprint(w, `{ "dismissal_restrictions":{ "users":[{"id":1,"login":"u"}], "teams":[{"id":2,"slug":"t"}], @@ -2979,7 +2979,7 @@ func TestRepositoriesService_DisableDismissalRestrictions(t *testing.T) { // TODO: remove custom Accept header when this API fully launches testHeader(t, r, "Accept", mediaTypeRequiredApprovingReviewsPreview) testBody(t, r, `{"dismissal_restrictions":{}}`+"\n") - fmt.Fprintf(w, `{"dismiss_stale_reviews":true,"require_code_owner_reviews":true,"required_approving_review_count":1}`) + fmt.Fprint(w, `{"dismiss_stale_reviews":true,"require_code_owner_reviews":true,"required_approving_review_count":1}`) }) ctx := context.Background() @@ -3071,7 +3071,7 @@ func TestRepositoriesService_GetAdminEnforcement(t *testing.T) { mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprintf(w, `{"url":"/https/github.com/repos/o/r/branches/b/protection/enforce_admins","enabled":true}`) + fmt.Fprint(w, `{"url":"/https/github.com/repos/o/r/branches/b/protection/enforce_admins","enabled":true}`) }) ctx := context.Background() @@ -3123,7 +3123,7 @@ func TestRepositoriesService_AddAdminEnforcement(t *testing.T) { mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") - fmt.Fprintf(w, `{"url":"/https/github.com/repos/o/r/branches/b/protection/enforce_admins","enabled":true}`) + fmt.Fprint(w, `{"url":"/https/github.com/repos/o/r/branches/b/protection/enforce_admins","enabled":true}`) }) ctx := context.Background() @@ -3214,7 +3214,7 @@ func TestRepositoriesService_GetSignaturesProtectedBranch(t *testing.T) { mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testHeader(t, r, "Accept", mediaTypeSignaturePreview) - fmt.Fprintf(w, `{"url":"/https/github.com/repos/o/r/branches/b/protection/required_signatures","enabled":false}`) + fmt.Fprint(w, `{"url":"/https/github.com/repos/o/r/branches/b/protection/required_signatures","enabled":false}`) }) ctx := context.Background() @@ -3267,7 +3267,7 @@ func TestRepositoriesService_RequireSignaturesOnProtectedBranch(t *testing.T) { mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") testHeader(t, r, "Accept", mediaTypeSignaturePreview) - fmt.Fprintf(w, `{"url":"/https/github.com/repos/o/r/branches/b/protection/required_signatures","enabled":true}`) + fmt.Fprint(w, `{"url":"/https/github.com/repos/o/r/branches/b/protection/required_signatures","enabled":true}`) }) ctx := context.Background() @@ -4552,7 +4552,7 @@ func TestRepository_UnmarshalJSON(t *testing.T) { pk := Repository{} err := json.Unmarshal(tt.data, &pk) if err == nil && tt.wantErr { - t.Errorf("Repository.UnmarshalJSON returned nil instead of an error") + t.Error("Repository.UnmarshalJSON returned nil instead of an error") } if err != nil && !tt.wantErr { t.Errorf("Repository.UnmarshalJSON returned an unexpected error: %+v", err) diff --git a/github/repos_traffic_test.go b/github/repos_traffic_test.go index e1374d8c461..7dfa128b7c4 100644 --- a/github/repos_traffic_test.go +++ b/github/repos_traffic_test.go @@ -21,7 +21,7 @@ func TestRepositoriesService_ListTrafficReferrers(t *testing.T) { mux.HandleFunc("/repos/o/r/traffic/popular/referrers", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprintf(w, `[{ + fmt.Fprint(w, `[{ "referrer": "Google", "count": 4, "uniques": 3 @@ -63,7 +63,7 @@ func TestRepositoriesService_ListTrafficPaths(t *testing.T) { mux.HandleFunc("/repos/o/r/traffic/popular/paths", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprintf(w, `[{ + fmt.Fprint(w, `[{ "path": "/github/hubot", "title": "github/hubot: A customizable life embetterment robot.", "count": 3542, @@ -107,7 +107,7 @@ func TestRepositoriesService_ListTrafficViews(t *testing.T) { mux.HandleFunc("/repos/o/r/traffic/views", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprintf(w, `{"count": 7, + fmt.Fprint(w, `{"count": 7, "uniques": 6, "views": [{ "timestamp": "2016-05-31T16:00:00.000Z", @@ -157,7 +157,7 @@ func TestRepositoriesService_ListTrafficClones(t *testing.T) { mux.HandleFunc("/repos/o/r/traffic/clones", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprintf(w, `{"count": 7, + fmt.Fprint(w, `{"count": 7, "uniques": 6, "clones": [{ "timestamp": "2016-05-31T16:00:00.00Z", diff --git a/github/security_advisories_test.go b/github/security_advisories_test.go index ff421db49d9..a10460c626a 100644 --- a/github/security_advisories_test.go +++ b/github/security_advisories_test.go @@ -535,7 +535,7 @@ func TestSecurityAdvisoriesService_ListRepositorySecurityAdvisoriesForOrg_BadReq ctx := context.Background() advisories, resp, err := client.SecurityAdvisories.ListRepositorySecurityAdvisoriesForOrg(ctx, "o", nil) if err == nil { - t.Errorf("Expected HTTP 400 response") + t.Error("Expected HTTP 400 response") } if got, want := resp.Response.StatusCode, http.StatusBadRequest; got != want { t.Errorf("ListRepositorySecurityAdvisoriesForOrg return status %d, want %d", got, want) @@ -565,7 +565,7 @@ func TestSecurityAdvisoriesService_ListRepositorySecurityAdvisoriesForOrg_NotFou State: "draft", }) if err == nil { - t.Errorf("Expected HTTP 404 response") + t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { t.Errorf("ListRepositorySecurityAdvisoriesForOrg return status %d, want %d", got, want) @@ -589,7 +589,7 @@ func TestSecurityAdvisoriesService_ListRepositorySecurityAdvisoriesForOrg_Unmars ctx := context.Background() advisories, resp, err := client.SecurityAdvisories.ListRepositorySecurityAdvisoriesForOrg(ctx, "o", nil) if err == nil { - t.Errorf("Expected unmarshal error") + t.Error("Expected unmarshal error") } else if !strings.Contains(err.Error(), "json: cannot unmarshal number into Go struct field SecurityAdvisory.ghsa_id of type string") { t.Errorf("ListRepositorySecurityAdvisoriesForOrg returned unexpected error: %v", err) } @@ -666,7 +666,7 @@ func TestSecurityAdvisoriesService_ListRepositorySecurityAdvisories_BadRequest(t ctx := context.Background() advisories, resp, err := client.SecurityAdvisories.ListRepositorySecurityAdvisories(ctx, "o", "r", nil) if err == nil { - t.Errorf("Expected HTTP 400 response") + t.Error("Expected HTTP 400 response") } if got, want := resp.Response.StatusCode, http.StatusBadRequest; got != want { t.Errorf("ListRepositorySecurityAdvisories return status %d, want %d", got, want) @@ -696,7 +696,7 @@ func TestSecurityAdvisoriesService_ListRepositorySecurityAdvisories_NotFound(t * State: "draft", }) if err == nil { - t.Errorf("Expected HTTP 404 response") + t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { t.Errorf("ListRepositorySecurityAdvisories return status %d, want %d", got, want) @@ -720,7 +720,7 @@ func TestSecurityAdvisoriesService_ListRepositorySecurityAdvisories_UnmarshalErr ctx := context.Background() advisories, resp, err := client.SecurityAdvisories.ListRepositorySecurityAdvisories(ctx, "o", "r", nil) if err == nil { - t.Errorf("Expected unmarshal error") + t.Error("Expected unmarshal error") } else if !strings.Contains(err.Error(), "json: cannot unmarshal number into Go struct field SecurityAdvisory.ghsa_id of type string") { t.Errorf("ListRepositorySecurityAdvisories returned unexpected error: %v", err) } diff --git a/github/teams_discussion_comments_test.go b/github/teams_discussion_comments_test.go index e49fb9dc9d4..d0c6ba7d273 100644 --- a/github/teams_discussion_comments_test.go +++ b/github/teams_discussion_comments_test.go @@ -43,7 +43,7 @@ func TestTeamsService_ListComments(t *testing.T) { testFormValues(t, r, values{ "direction": "desc", }) - fmt.Fprintf(w, + fmt.Fprint(w, `[ { "author": { diff --git a/github/teams_discussions_test.go b/github/teams_discussions_test.go index 169f85736df..dffd2885556 100644 --- a/github/teams_discussions_test.go +++ b/github/teams_discussions_test.go @@ -26,7 +26,7 @@ func TestTeamsService_ListDiscussionsByID(t *testing.T) { "direction": "desc", "page": "2", }) - fmt.Fprintf(w, + fmt.Fprint(w, `[ { "author": { @@ -141,7 +141,7 @@ func TestTeamsService_ListDiscussionsBySlug(t *testing.T) { "direction": "desc", "page": "2", }) - fmt.Fprintf(w, + fmt.Fprint(w, `[ { "author": { diff --git a/github/teams_members_test.go b/github/teams_members_test.go index 4cd41d4fc2a..b0eb6a9f6ea 100644 --- a/github/teams_members_test.go +++ b/github/teams_members_test.go @@ -66,7 +66,7 @@ func TestTeamsService__ListTeamMembersByID_notFound(t *testing.T) { ctx := context.Background() members, resp, err := client.Teams.ListTeamMembersByID(ctx, 1, 2, opt) if err == nil { - t.Errorf("Expected HTTP 404 response") + t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { t.Errorf("Teams.ListTeamMembersByID returned status %d, want %d", got, want) @@ -141,7 +141,7 @@ func TestTeamsService__ListTeamMembersBySlug_notFound(t *testing.T) { ctx := context.Background() members, resp, err := client.Teams.ListTeamMembersBySlug(ctx, "o", "s", opt) if err == nil { - t.Errorf("Expected HTTP 404 response") + t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { t.Errorf("Teams.ListTeamMembersBySlug returned status %d, want %d", got, want) @@ -221,7 +221,7 @@ func TestTeamsService__GetTeamMembershipByID_notFound(t *testing.T) { ctx := context.Background() membership, resp, err := client.Teams.GetTeamMembershipByID(ctx, 1, 2, "u") if err == nil { - t.Errorf("Expected HTTP 404 response") + t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { t.Errorf("Teams.GetTeamMembershipByID returned status %d, want %d", got, want) @@ -292,7 +292,7 @@ func TestTeamsService__GetTeamMembershipBySlug_notFound(t *testing.T) { ctx := context.Background() membership, resp, err := client.Teams.GetTeamMembershipBySlug(ctx, "o", "s", "u") if err == nil { - t.Errorf("Expected HTTP 404 response") + t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { t.Errorf("Teams.GetTeamMembershipBySlug returned status %d, want %d", got, want) @@ -390,7 +390,7 @@ func TestTeamsService__AddTeamMembershipByID_notFound(t *testing.T) { ctx := context.Background() membership, resp, err := client.Teams.AddTeamMembershipByID(ctx, 1, 2, "u", opt) if err == nil { - t.Errorf("Expected HTTP 404 response") + t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { t.Errorf("Teams.AddTeamMembershipByID returned status %d, want %d", got, want) @@ -479,7 +479,7 @@ func TestTeamsService__AddTeamMembershipBySlug_notFound(t *testing.T) { ctx := context.Background() membership, resp, err := client.Teams.AddTeamMembershipBySlug(ctx, "o", "s", "u", opt) if err == nil { - t.Errorf("Expected HTTP 404 response") + t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { t.Errorf("Teams.AddTeamMembershipBySlug returned status %d, want %d", got, want) @@ -550,7 +550,7 @@ func TestTeamsService__RemoveTeamMembershipByID_notFound(t *testing.T) { ctx := context.Background() resp, err := client.Teams.RemoveTeamMembershipByID(ctx, 1, 2, "u") if err == nil { - t.Errorf("Expected HTTP 404 response") + t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { t.Errorf("Teams.RemoveTeamMembershipByID returned status %d, want %d", got, want) @@ -605,7 +605,7 @@ func TestTeamsService__RemoveTeamMembershipBySlug_notFound(t *testing.T) { ctx := context.Background() resp, err := client.Teams.RemoveTeamMembershipBySlug(ctx, "o", "s", "u") if err == nil { - t.Errorf("Expected HTTP 404 response") + t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { t.Errorf("Teams.RemoveTeamMembershipBySlug returned status %d, want %d", got, want) @@ -682,7 +682,7 @@ func TestTeamsService__ListPendingTeamInvitationsByID_notFound(t *testing.T) { ctx := context.Background() invitations, resp, err := client.Teams.ListPendingTeamInvitationsByID(ctx, 1, 2, opt) if err == nil { - t.Errorf("Expected HTTP 404 response") + t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { t.Errorf("Teams.RemoveTeamMembershipByID returned status %d, want %d", got, want) @@ -757,7 +757,7 @@ func TestTeamsService__ListPendingTeamInvitationsBySlug_notFound(t *testing.T) { ctx := context.Background() invitations, resp, err := client.Teams.ListPendingTeamInvitationsBySlug(ctx, "o", "s", opt) if err == nil { - t.Errorf("Expected HTTP 404 response") + t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { t.Errorf("Teams.RemoveTeamMembershipByID returned status %d, want %d", got, want) diff --git a/github/teams_test.go b/github/teams_test.go index 0c230c121c6..30c2796855f 100644 --- a/github/teams_test.go +++ b/github/teams_test.go @@ -110,7 +110,7 @@ func TestTeamsService_GetTeamByID_notFound(t *testing.T) { ctx := context.Background() team, resp, err := client.Teams.GetTeamByID(ctx, 1, 2) if err == nil { - t.Errorf("Expected HTTP 404 response") + t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { t.Errorf("Teams.GetTeamByID returned status %d, want %d", got, want) @@ -176,7 +176,7 @@ func TestTeamsService_GetTeamBySlug_notFound(t *testing.T) { ctx := context.Background() team, resp, err := client.Teams.GetTeamBySlug(ctx, "o", "s") if err == nil { - t.Errorf("Expected HTTP 404 response") + t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { t.Errorf("Teams.GetTeamBySlug returned status %d, want %d", got, want) @@ -691,7 +691,7 @@ func TestTeamsService_IsTeamRepoByID_false(t *testing.T) { ctx := context.Background() repo, resp, err := client.Teams.IsTeamRepoByID(ctx, 1, 1, "owner", "repo") if err == nil { - t.Errorf("Expected HTTP 404 response") + t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { t.Errorf("Teams.IsTeamRepoByID returned status %d, want %d", got, want) @@ -713,7 +713,7 @@ func TestTeamsService_IsTeamRepoBySlug_false(t *testing.T) { ctx := context.Background() repo, resp, err := client.Teams.IsTeamRepoBySlug(ctx, "org", "slug", "owner", "repo") if err == nil { - t.Errorf("Expected HTTP 404 response") + t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { t.Errorf("Teams.IsTeamRepoByID returned status %d, want %d", got, want) @@ -735,7 +735,7 @@ func TestTeamsService_IsTeamRepoByID_error(t *testing.T) { ctx := context.Background() repo, resp, err := client.Teams.IsTeamRepoByID(ctx, 1, 1, "owner", "repo") if err == nil { - t.Errorf("Expected HTTP 400 response") + t.Error("Expected HTTP 400 response") } if got, want := resp.Response.StatusCode, http.StatusBadRequest; got != want { t.Errorf("Teams.IsTeamRepoByID returned status %d, want %d", got, want) @@ -757,7 +757,7 @@ func TestTeamsService_IsTeamRepoBySlug_error(t *testing.T) { ctx := context.Background() repo, resp, err := client.Teams.IsTeamRepoBySlug(ctx, "org", "slug", "owner", "repo") if err == nil { - t.Errorf("Expected HTTP 400 response") + t.Error("Expected HTTP 400 response") } if got, want := resp.Response.StatusCode, http.StatusBadRequest; got != want { t.Errorf("Teams.IsTeamRepoBySlug returned status %d, want %d", got, want) @@ -867,7 +867,7 @@ func TestTeamsService_AddTeamRepoByID_noAccess(t *testing.T) { ctx := context.Background() _, err := client.Teams.AddTeamRepoByID(ctx, 1, 1, "owner", "repo", nil) if err == nil { - t.Errorf("Expected error to be returned") + t.Error("Expected error to be returned") } } @@ -883,7 +883,7 @@ func TestTeamsService_AddTeamRepoBySlug_noAccess(t *testing.T) { ctx := context.Background() _, err := client.Teams.AddTeamRepoBySlug(ctx, "org", "slug", "owner", "repo", nil) if err == nil { - t.Errorf("Expected error to be returned") + t.Error("Expected error to be returned") } } @@ -1846,7 +1846,7 @@ func TestTeamsService_GetExternalGroup_notFound(t *testing.T) { ctx := context.Background() eg, resp, err := client.Teams.GetExternalGroup(ctx, "o", 123) if err == nil { - t.Errorf("Expected HTTP 404 response") + t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { t.Errorf("Teams.GetExternalGroup returned status %d, want %d", got, want) @@ -1922,7 +1922,7 @@ func TestTeamsService_ListExternalGroups_notFound(t *testing.T) { ctx := context.Background() eg, resp, err := client.Teams.ListExternalGroups(ctx, "o", nil) if err == nil { - t.Errorf("Expected HTTP 404 response") + t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { t.Errorf("Teams.ListExternalGroups returned status %d, want %d", got, want) @@ -1995,7 +1995,7 @@ func TestTeamsService_ListExternalGroupsForTeamBySlug_notFound(t *testing.T) { ctx := context.Background() eg, resp, err := client.Teams.ListExternalGroupsForTeamBySlug(ctx, "o", "t") if err == nil { - t.Errorf("Expected HTTP 404 response") + t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { t.Errorf("Teams.ListExternalGroupsForTeamBySlug returned status %d, want %d", got, want) @@ -2114,7 +2114,7 @@ func TestTeamsService_UpdateConnectedExternalGroup_notFound(t *testing.T) { } eg, resp, err := client.Teams.UpdateConnectedExternalGroup(ctx, "o", "t", body) if err == nil { - t.Errorf("Expected HTTP 404 response") + t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { t.Errorf("Teams.UpdateConnectedExternalGroup returned status %d, want %d", got, want) @@ -2162,7 +2162,7 @@ func TestTeamsService_RemoveConnectedExternalGroup_notFound(t *testing.T) { ctx := context.Background() resp, err := client.Teams.RemoveConnectedExternalGroup(ctx, "o", "t") if err == nil { - t.Errorf("Expected HTTP 404 response") + t.Error("Expected HTTP 404 response") } if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want { t.Errorf("Teams.GetExternalGroup returned status %d, want %d", got, want) diff --git a/github/users_followers_test.go b/github/users_followers_test.go index 5f0de89ab19..1c2fe9e3ac4 100644 --- a/github/users_followers_test.go +++ b/github/users_followers_test.go @@ -287,7 +287,7 @@ func TestUsersService_IsFollowing_error(t *testing.T) { ctx := context.Background() following, _, err := client.Users.IsFollowing(ctx, "u", "t") if err == nil { - t.Errorf("Expected HTTP 400 response") + t.Error("Expected HTTP 400 response") } if want := false; following != want { t.Errorf("Users.IsFollowing returned %+v, want %+v", following, want) diff --git a/github/users_test.go b/github/users_test.go index 96332b15567..290d11937eb 100644 --- a/github/users_test.go +++ b/github/users_test.go @@ -359,7 +359,7 @@ func TestUsersService_ListInvitations(t *testing.T) { mux.HandleFunc("/user/repository_invitations", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprintf(w, `[{"id":1}, {"id":2}]`) + fmt.Fprint(w, `[{"id":1}, {"id":2}]`) }) ctx := context.Background() @@ -392,7 +392,7 @@ func TestUsersService_ListInvitations_withOptions(t *testing.T) { testFormValues(t, r, values{ "page": "2", }) - fmt.Fprintf(w, `[{"id":1}, {"id":2}]`) + fmt.Fprint(w, `[{"id":1}, {"id":2}]`) }) ctx := context.Background() diff --git a/script/lint.sh b/script/lint.sh index eabd5046077..c3d897d0a2d 100755 --- a/script/lint.sh +++ b/script/lint.sh @@ -5,7 +5,7 @@ set -e -GOLANGCI_LINT_VERSION="2.1.6" +GOLANGCI_LINT_VERSION="2.2.2" CDPATH="" cd -- "$(dirname -- "$0")/.." BIN="$(pwd -P)"/bin diff --git a/test/integration/audit_log_test.go b/test/integration/audit_log_test.go index 34fd5cdffb3..58f4a3313ee 100644 --- a/test/integration/audit_log_test.go +++ b/test/integration/audit_log_test.go @@ -23,7 +23,7 @@ func TestOrganizationAuditLog(t *testing.T) { } if len(entries) == 0 { - t.Errorf("No AuditLog events returned for org") + t.Error("No AuditLog events returned for org") } for _, e := range entries { diff --git a/test/integration/issues_test.go b/test/integration/issues_test.go index 9a5d95ca3bf..00c0483bdd0 100644 --- a/test/integration/issues_test.go +++ b/test/integration/issues_test.go @@ -19,7 +19,7 @@ func TestIssueEvents(t *testing.T) { } if len(events) == 0 { - t.Errorf("ListRepositoryEvents returned no events") + t.Error("ListRepositoryEvents returned no events") } events, _, err = client.Issues.ListIssueEvents(context.Background(), "google", "go-github", 1, nil) @@ -28,7 +28,7 @@ func TestIssueEvents(t *testing.T) { } if len(events) == 0 { - t.Errorf("ListIssueEvents returned no events") + t.Error("ListIssueEvents returned no events") } event, _, err := client.Issues.GetEvent(context.Background(), "google", "go-github", *events[0].ID) diff --git a/test/integration/misc_test.go b/test/integration/misc_test.go index 3390666c57c..da3d694e225 100644 --- a/test/integration/misc_test.go +++ b/test/integration/misc_test.go @@ -20,11 +20,11 @@ func TestEmojis(t *testing.T) { } if len(emoji) == 0 { - t.Errorf("List returned no emojis") + t.Error("List returned no emojis") } if _, ok := emoji["+1"]; !ok { - t.Errorf("List missing '+1' emoji") + t.Error("List missing '+1' emoji") } } @@ -35,15 +35,15 @@ func TestAPIMeta(t *testing.T) { } if len(meta.Hooks) == 0 { - t.Errorf("Get returned no hook addresses") + t.Error("Get returned no hook addresses") } if len(meta.Git) == 0 { - t.Errorf("Get returned no git addresses") + t.Error("Get returned no git addresses") } if !*meta.VerifiablePasswordAuthentication { - t.Errorf("APIMeta VerifiablePasswordAuthentication is false") + t.Error("APIMeta VerifiablePasswordAuthentication is false") } } @@ -55,14 +55,14 @@ func TestRateLimits(t *testing.T) { // do some sanity checks if limits.Core.Limit == 0 { - t.Errorf("RateLimits returned 0 core limit") + t.Error("RateLimits returned 0 core limit") } if limits.Core.Limit < limits.Core.Remaining { - t.Errorf("Core.Limits is less than Core.Remaining.") + t.Error("Core.Limits is less than Core.Remaining.") } if limits.Core.Reset.Time.Before(time.Now().Add(-1 * time.Minute)) { - t.Errorf("Core.Reset is more than 1 minute in the past; that doesn't seem right.") + t.Error("Core.Reset is more than 1 minute in the past; that doesn't seem right.") } } diff --git a/test/integration/repos_test.go b/test/integration/repos_test.go index 8e735ffd21f..925afa01a7c 100644 --- a/test/integration/repos_test.go +++ b/test/integration/repos_test.go @@ -45,7 +45,7 @@ func TestRepositories_CRUD(t *testing.T) { // verify that the repository was deleted _, resp, err := client.Repositories.Get(context.Background(), *repo.Owner.Login, *repo.Name) if err == nil { - t.Fatalf("Test repository still exists after deleting it.") + t.Fatal("Test repository still exists after deleting it.") } if err != nil && resp.StatusCode != http.StatusNotFound { t.Fatalf("Repositories.Get() returned error: %v", err) @@ -60,7 +60,7 @@ func TestRepositories_BranchesTags(t *testing.T) { } if len(branches) == 0 { - t.Fatalf("Repositories.ListBranches('git', 'git') returned no branches") + t.Fatal("Repositories.ListBranches('git', 'git') returned no branches") } _, _, err = client.Repositories.GetBranch(context.Background(), "git", "git", *branches[0].Name, 0) @@ -75,7 +75,7 @@ func TestRepositories_BranchesTags(t *testing.T) { } if len(tags) == 0 { - t.Fatalf("Repositories.ListTags('git', 'git') returned no tags") + t.Fatal("Repositories.ListTags('git', 'git') returned no tags") } } @@ -180,7 +180,7 @@ func TestRepositories_ListByUser(t *testing.T) { } for i, repo := range repos { if i > 0 && (*repos[i-1].CreatedAt).Time.Before((*repo.CreatedAt).Time) { - t.Fatalf("Repositories.ListByUser('google') with default descending Sort returned incorrect order") + t.Fatal("Repositories.ListByUser('google') with default descending Sort returned incorrect order") } } } diff --git a/test/integration/users_test.go b/test/integration/users_test.go index c0bfca1c5dd..e15a54cdcbf 100644 --- a/test/integration/users_test.go +++ b/test/integration/users_test.go @@ -24,7 +24,7 @@ func TestUsers_Get(t *testing.T) { } if len(users) == 0 { - t.Errorf("Users.ListAll returned no users") + t.Error("Users.ListAll returned no users") } // mojombo is user #1 @@ -57,7 +57,7 @@ func TestUsers_Update(t *testing.T) { } if *u.Login == "" { - t.Errorf("wanted non-empty values for user.Login") + t.Error("wanted non-empty values for user.Login") } // save original location @@ -166,7 +166,7 @@ func TestUsers_Keys(t *testing.T) { } if len(keys) == 0 { - t.Errorf("Users.ListKeys('willnorris') returned no keys") + t.Error("Users.ListKeys('willnorris') returned no keys") } // the rest of the tests requires auth @@ -184,7 +184,7 @@ func TestUsers_Keys(t *testing.T) { key := "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCy/RIqaMFj2wjkOEjx9EAU0ReLAIhodga82/feo5nnT9UUkHLbL9xrIavfdLHx28lD3xYgPfAoSicUMaAeNwuQhmuerr2c2LFGxzrdXP8pVsQ+Ol7y7OdmFPfe0KrzoZaLJs9aSiZ4VKyY4z5Se/k2UgcJTdgQVlLfw/P96aqCx8yUu94BiWqkDqYEvgWKRNHrTiIo1EXeVBCCcfgNZe1suFfNJUJSUU2T3EG2bpwBbSOCjE3FyH8+Lz3K3BOGzm3df8E7Regj9j4YIcD8cWJYO86jLJoGgQ0L5MSOq+ishNaHQXech22Ix03D1lVMjCvDT7S/C94Z1LzhI2lhvyff" for _, k := range keys { if k.Key != nil && *k.Key == key { - t.Fatalf("Test key already exists for user. Please manually remove it first.") + t.Fatal("Test key already exists for user. Please manually remove it first.") } } @@ -212,7 +212,7 @@ func TestUsers_Keys(t *testing.T) { } if id == 0 { - t.Fatalf("Users.ListKeys('') does not contain added test key") + t.Fatal("Users.ListKeys('') does not contain added test key") } // Verify that fetching individual key works @@ -238,7 +238,7 @@ func TestUsers_Keys(t *testing.T) { for _, k := range keys { if k.Key != nil && *k.Key == key { - t.Fatalf("Users.ListKeys('') still contains test key after removing it") + t.Fatal("Users.ListKeys('') still contains test key after removing it") } } } From 99ffabedb43df571084c0a97d5cd53002600bae2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Jul 2025 19:34:55 -0400 Subject: [PATCH 23/26] build(deps): bump github.com/alecthomas/kong from 1.12.0 to 1.12.1 in /tools (#3632) --- tools/go.mod | 2 +- tools/go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/go.mod b/tools/go.mod index 2ac0927482f..76d8b25ed23 100644 --- a/tools/go.mod +++ b/tools/go.mod @@ -3,7 +3,7 @@ module tools go 1.23.0 require ( - github.com/alecthomas/kong v1.12.0 + github.com/alecthomas/kong v1.12.1 github.com/getkin/kin-openapi v0.132.0 github.com/google/go-cmp v0.7.0 github.com/google/go-github/v73 v73.0.0 diff --git a/tools/go.sum b/tools/go.sum index a1ad9084d8a..6db3397af67 100644 --- a/tools/go.sum +++ b/tools/go.sum @@ -1,7 +1,7 @@ github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0= github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= -github.com/alecthomas/kong v1.12.0 h1:oKd/0fHSdajj5PfGDd3ScvEvpVJf9mT2mb5r9xYadYM= -github.com/alecthomas/kong v1.12.0/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU= +github.com/alecthomas/kong v1.12.1 h1:iq6aMJDcFYP9uFrLdsiZQ2ZMmcshduyGv4Pek0MQPW0= +github.com/alecthomas/kong v1.12.1/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU= github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc= github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= From 6540c41b390f4cf77386829dac8e60109ca0a3d9 Mon Sep 17 00:00:00 2001 From: Steve Hipwell Date: Tue, 22 Jul 2025 12:53:56 +0100 Subject: [PATCH 24/26] fix!: Change `ListCheckSuiteOptions.AppID` from `int` to `int64` (#3633) BREAKING CHANGE: Change `ListCheckSuiteOptions.AppID` from `int` to `int64` --- github/checks.go | 2 +- github/checks_test.go | 2 +- github/github-accessors.go | 2 +- github/github-accessors_test.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/github/checks.go b/github/checks.go index 2f0f65bf92a..6f9c4191cda 100644 --- a/github/checks.go +++ b/github/checks.go @@ -345,7 +345,7 @@ func (s *ChecksService) ReRequestCheckRun(ctx context.Context, owner, repo strin // ListCheckSuiteOptions represents parameters to list check suites. type ListCheckSuiteOptions struct { CheckName *string `url:"check_name,omitempty"` // Filters checks suites by the name of the check run. - AppID *int `url:"app_id,omitempty"` // Filters check suites by GitHub App id. + AppID *int64 `url:"app_id,omitempty"` // Filters check suites by GitHub App id. ListOptions } diff --git a/github/checks_test.go b/github/checks_test.go index fac30ec2871..b451caab588 100644 --- a/github/checks_test.go +++ b/github/checks_test.go @@ -472,7 +472,7 @@ func TestChecksService_ListCheckSuiteForRef(t *testing.T) { opt := &ListCheckSuiteOptions{ CheckName: Ptr("testing"), - AppID: Ptr(2), + AppID: Ptr(int64(2)), ListOptions: ListOptions{Page: 1}, } ctx := context.Background() diff --git a/github/github-accessors.go b/github/github-accessors.go index ad06c78c9fa..6526a7c6675 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -13319,7 +13319,7 @@ func (l *ListCheckRunsResults) GetTotal() int { } // GetAppID returns the AppID field if it's non-nil, zero value otherwise. -func (l *ListCheckSuiteOptions) GetAppID() int { +func (l *ListCheckSuiteOptions) GetAppID() int64 { if l == nil || l.AppID == nil { return 0 } diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 0abd03fe319..b0201a7302e 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -17269,7 +17269,7 @@ func TestListCheckRunsResults_GetTotal(tt *testing.T) { func TestListCheckSuiteOptions_GetAppID(tt *testing.T) { tt.Parallel() - var zeroValue int + var zeroValue int64 l := &ListCheckSuiteOptions{AppID: &zeroValue} l.GetAppID() l = &ListCheckSuiteOptions{} From 49207f473aea22e65e2b47f2d780f602358ed383 Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Wed, 23 Jul 2025 16:30:03 +0300 Subject: [PATCH 25/26] docs: Extend RepositoryContentGetOptions description (#3637) --- github/repos_contents.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/repos_contents.go b/github/repos_contents.go index 5d7329c4ffe..3b24b6d4e6d 100644 --- a/github/repos_contents.go +++ b/github/repos_contents.go @@ -62,7 +62,7 @@ type RepositoryContentFileOptions struct { } // RepositoryContentGetOptions represents an optional ref parameter, which can be a SHA, -// branch, or tag. +// branch, or tag. E.g., `6540c41b`, `heads/main`, `tags/v1.0`. type RepositoryContentGetOptions struct { Ref string `url:"ref,omitempty"` } From 98d3588ee14aa2016cf74b98d8335977e111ee33 Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Wed, 23 Jul 2025 09:47:01 -0400 Subject: [PATCH 26/26] Bump version of go-github to v74.0.0 (#3638) --- README.md | 18 +++++++++--------- example/actionpermissions/main.go | 2 +- example/appengine/app.go | 2 +- example/basicauth/main.go | 2 +- .../newreposecretwithxcrypto/main.go | 2 +- .../newusersecretwithxcrypto/main.go | 2 +- example/commitpr/main.go | 2 +- example/go.mod | 6 +++--- example/listenvironments/main.go | 2 +- example/migrations/main.go | 2 +- example/newfilewithappauth/main.go | 2 +- example/newrepo/main.go | 2 +- example/newreposecretwithlibsodium/go.mod | 4 ++-- example/newreposecretwithlibsodium/main.go | 2 +- example/newreposecretwithxcrypto/main.go | 2 +- example/ratelimit/main.go | 2 +- example/simple/main.go | 2 +- example/tokenauth/main.go | 2 +- example/topics/main.go | 2 +- example/verifyartifact/main.go | 2 +- github/doc.go | 2 +- github/examples_test.go | 2 +- github/github.go | 2 +- go.mod | 2 +- test/fields/fields.go | 2 +- test/integration/activity_test.go | 2 +- test/integration/authorizations_test.go | 2 +- test/integration/github_test.go | 2 +- test/integration/repos_test.go | 2 +- test/integration/users_test.go | 2 +- tools/go.mod | 4 ++-- tools/metadata/main.go | 2 +- tools/metadata/main_test.go | 2 +- tools/metadata/metadata.go | 2 +- tools/metadata/openapi.go | 2 +- 35 files changed, 47 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index 907846821ad..234152e2b88 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # go-github # [![go-github release (latest SemVer)](https://img.shields.io/github/v/release/google/go-github?sort=semver)](https://github.com/google/go-github/releases) -[![Go Reference](https://img.shields.io/static/v1?label=godoc&message=reference&color=blue)](https://pkg.go.dev/github.com/google/go-github/v73/github) +[![Go Reference](https://img.shields.io/static/v1?label=godoc&message=reference&color=blue)](https://pkg.go.dev/github.com/google/go-github/v74/github) [![Test Status](https://github.com/google/go-github/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/google/go-github/actions/workflows/tests.yml) [![Test Coverage](https://codecov.io/gh/google/go-github/branch/master/graph/badge.svg)](https://codecov.io/gh/google/go-github) [![Discuss at go-github@googlegroups.com](https://img.shields.io/badge/discuss-go--github%40googlegroups.com-blue.svg)](https://groups.google.com/group/go-github) @@ -30,7 +30,7 @@ If you're interested in using the [GraphQL API v4][], the recommended library is go-github is compatible with modern Go releases in module mode, with Go installed: ```bash -go get github.com/google/go-github/v73 +go get github.com/google/go-github/v74 ``` will resolve and add the package to the current development module, along with its dependencies. @@ -38,7 +38,7 @@ will resolve and add the package to the current development module, along with i Alternatively the same can be achieved if you use import in a package: ```go -import "github.com/google/go-github/v73/github" +import "github.com/google/go-github/v74/github" ``` and run `go get` without parameters. @@ -46,13 +46,13 @@ and run `go get` without parameters. Finally, to use the top-of-trunk version of this repo, use the following command: ```bash -go get github.com/google/go-github/v73@master +go get github.com/google/go-github/v74@master ``` ## Usage ## ```go -import "github.com/google/go-github/v73/github" // with go modules enabled (GO111MODULE=on or outside GOPATH) +import "github.com/google/go-github/v74/github" // with go modules enabled (GO111MODULE=on or outside GOPATH) import "github.com/google/go-github/github" // with go modules disabled ``` @@ -125,7 +125,7 @@ import ( "net/http" "github.com/bradleyfalzon/ghinstallation/v2" - "github.com/google/go-github/v73/github" + "github.com/google/go-github/v74/github" ) func main() { @@ -159,7 +159,7 @@ import ( "os" "strconv" - "github.com/google/go-github/v73/github" + "github.com/google/go-github/v74/github" "github.com/jferrl/go-githubauth" "golang.org/x/oauth2" ) @@ -400,7 +400,7 @@ For complete usage of go-github, see the full [package docs][]. [GitHub API v3]: https://docs.github.com/en/rest [personal access token]: https://github.com/blog/1509-personal-api-tokens -[package docs]: https://pkg.go.dev/github.com/google/go-github/v73/github +[package docs]: https://pkg.go.dev/github.com/google/go-github/v74/github [GraphQL API v4]: https://developer.github.com/v4/ [shurcooL/githubv4]: https://github.com/shurcooL/githubv4 [GitHub webhook events]: https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads @@ -474,7 +474,7 @@ Versions prior to 48.2.0 are not listed. | go-github Version | GitHub v3 API Version | | ----------------- | --------------------- | -| 73.0.0 | 2022-11-28 | +| 74.0.0 | 2022-11-28 | | ... | 2022-11-28 | | 48.2.0 | 2022-11-28 | diff --git a/example/actionpermissions/main.go b/example/actionpermissions/main.go index 2c45455b1fd..29fe74eb288 100644 --- a/example/actionpermissions/main.go +++ b/example/actionpermissions/main.go @@ -14,7 +14,7 @@ import ( "log" "os" - "github.com/google/go-github/v73/github" + "github.com/google/go-github/v74/github" ) var ( diff --git a/example/appengine/app.go b/example/appengine/app.go index 87606e6c23a..68410b0d33b 100644 --- a/example/appengine/app.go +++ b/example/appengine/app.go @@ -12,7 +12,7 @@ import ( "net/http" "os" - "github.com/google/go-github/v73/github" + "github.com/google/go-github/v74/github" "google.golang.org/appengine" "google.golang.org/appengine/log" ) diff --git a/example/basicauth/main.go b/example/basicauth/main.go index 70fc248b5c0..0cac5f40be6 100644 --- a/example/basicauth/main.go +++ b/example/basicauth/main.go @@ -21,7 +21,7 @@ import ( "os" "strings" - "github.com/google/go-github/v73/github" + "github.com/google/go-github/v74/github" "golang.org/x/term" ) diff --git a/example/codespaces/newreposecretwithxcrypto/main.go b/example/codespaces/newreposecretwithxcrypto/main.go index c05168c3100..74426f81e42 100644 --- a/example/codespaces/newreposecretwithxcrypto/main.go +++ b/example/codespaces/newreposecretwithxcrypto/main.go @@ -37,7 +37,7 @@ import ( "log" "os" - "github.com/google/go-github/v73/github" + "github.com/google/go-github/v74/github" "golang.org/x/crypto/nacl/box" ) diff --git a/example/codespaces/newusersecretwithxcrypto/main.go b/example/codespaces/newusersecretwithxcrypto/main.go index 340f5c84547..da267481e90 100644 --- a/example/codespaces/newusersecretwithxcrypto/main.go +++ b/example/codespaces/newusersecretwithxcrypto/main.go @@ -38,7 +38,7 @@ import ( "log" "os" - "github.com/google/go-github/v73/github" + "github.com/google/go-github/v74/github" "golang.org/x/crypto/nacl/box" ) diff --git a/example/commitpr/main.go b/example/commitpr/main.go index 5ab545a592d..ab30adb7e0a 100644 --- a/example/commitpr/main.go +++ b/example/commitpr/main.go @@ -33,7 +33,7 @@ import ( "time" "github.com/ProtonMail/go-crypto/openpgp" - "github.com/google/go-github/v73/github" + "github.com/google/go-github/v74/github" ) var ( diff --git a/example/go.mod b/example/go.mod index e103e3ffa65..a4d2cd23522 100644 --- a/example/go.mod +++ b/example/go.mod @@ -1,4 +1,4 @@ -module github.com/google/go-github/v73/example +module github.com/google/go-github/v74/example go 1.23.0 @@ -7,7 +7,7 @@ require ( github.com/bradleyfalzon/ghinstallation/v2 v2.0.4 github.com/gofri/go-github-pagination v1.0.0 github.com/gofri/go-github-ratelimit/v2 v2.0.2 - github.com/google/go-github/v73 v73.0.0 + github.com/google/go-github/v74 v74.0.0 github.com/sigstore/sigstore-go v0.6.1 golang.org/x/crypto v0.36.0 golang.org/x/term v0.30.0 @@ -100,4 +100,4 @@ require ( ) // Use version at HEAD, not the latest published. -replace github.com/google/go-github/v73 => ../ +replace github.com/google/go-github/v74 => ../ diff --git a/example/listenvironments/main.go b/example/listenvironments/main.go index a831d9d6894..3511015d24c 100644 --- a/example/listenvironments/main.go +++ b/example/listenvironments/main.go @@ -18,7 +18,7 @@ import ( "log" "os" - "github.com/google/go-github/v73/github" + "github.com/google/go-github/v74/github" ) func main() { diff --git a/example/migrations/main.go b/example/migrations/main.go index f818d4c1c40..953a46332c5 100644 --- a/example/migrations/main.go +++ b/example/migrations/main.go @@ -12,7 +12,7 @@ import ( "context" "fmt" - "github.com/google/go-github/v73/github" + "github.com/google/go-github/v74/github" ) func fetchAllUserMigrations() ([]*github.UserMigration, error) { diff --git a/example/newfilewithappauth/main.go b/example/newfilewithappauth/main.go index f7cf09bbae6..2a580a523e5 100644 --- a/example/newfilewithappauth/main.go +++ b/example/newfilewithappauth/main.go @@ -16,7 +16,7 @@ import ( "time" "github.com/bradleyfalzon/ghinstallation/v2" - "github.com/google/go-github/v73/github" + "github.com/google/go-github/v74/github" ) func main() { diff --git a/example/newrepo/main.go b/example/newrepo/main.go index 39809517780..5b1499972ce 100644 --- a/example/newrepo/main.go +++ b/example/newrepo/main.go @@ -16,7 +16,7 @@ import ( "log" "os" - "github.com/google/go-github/v73/github" + "github.com/google/go-github/v74/github" ) var ( diff --git a/example/newreposecretwithlibsodium/go.mod b/example/newreposecretwithlibsodium/go.mod index 5d28f4dba2e..a47d9b77cce 100644 --- a/example/newreposecretwithlibsodium/go.mod +++ b/example/newreposecretwithlibsodium/go.mod @@ -4,10 +4,10 @@ go 1.23.0 require ( github.com/GoKillers/libsodium-go v0.0.0-20171022220152-dd733721c3cb - github.com/google/go-github/v73 v73.0.0 + github.com/google/go-github/v74 v74.0.0 ) require github.com/google/go-querystring v1.1.0 // indirect // Use version at HEAD, not the latest published. -replace github.com/google/go-github/v73 => ../.. +replace github.com/google/go-github/v74 => ../.. diff --git a/example/newreposecretwithlibsodium/main.go b/example/newreposecretwithlibsodium/main.go index affdecfdc60..eb9abfdb997 100644 --- a/example/newreposecretwithlibsodium/main.go +++ b/example/newreposecretwithlibsodium/main.go @@ -36,7 +36,7 @@ import ( "os" sodium "github.com/GoKillers/libsodium-go/cryptobox" - "github.com/google/go-github/v73/github" + "github.com/google/go-github/v74/github" ) var ( diff --git a/example/newreposecretwithxcrypto/main.go b/example/newreposecretwithxcrypto/main.go index 7a2e4b9d72e..c57a45107c1 100644 --- a/example/newreposecretwithxcrypto/main.go +++ b/example/newreposecretwithxcrypto/main.go @@ -37,7 +37,7 @@ import ( "log" "os" - "github.com/google/go-github/v73/github" + "github.com/google/go-github/v74/github" "golang.org/x/crypto/nacl/box" ) diff --git a/example/ratelimit/main.go b/example/ratelimit/main.go index ef3024d8015..47172bc52b6 100644 --- a/example/ratelimit/main.go +++ b/example/ratelimit/main.go @@ -17,7 +17,7 @@ import ( "github.com/gofri/go-github-ratelimit/v2/github_ratelimit" "github.com/gofri/go-github-ratelimit/v2/github_ratelimit/github_primary_ratelimit" "github.com/gofri/go-github-ratelimit/v2/github_ratelimit/github_secondary_ratelimit" - "github.com/google/go-github/v73/github" + "github.com/google/go-github/v74/github" ) func main() { diff --git a/example/simple/main.go b/example/simple/main.go index 975ca18c284..276889129ff 100644 --- a/example/simple/main.go +++ b/example/simple/main.go @@ -12,7 +12,7 @@ import ( "context" "fmt" - "github.com/google/go-github/v73/github" + "github.com/google/go-github/v74/github" ) // Fetch all the public organizations' membership of a user. diff --git a/example/tokenauth/main.go b/example/tokenauth/main.go index bba59df2c95..6539b99f12f 100644 --- a/example/tokenauth/main.go +++ b/example/tokenauth/main.go @@ -15,7 +15,7 @@ import ( "log" "os" - "github.com/google/go-github/v73/github" + "github.com/google/go-github/v74/github" "golang.org/x/term" ) diff --git a/example/topics/main.go b/example/topics/main.go index 9800caed33e..0be1883e382 100644 --- a/example/topics/main.go +++ b/example/topics/main.go @@ -12,7 +12,7 @@ import ( "context" "fmt" - "github.com/google/go-github/v73/github" + "github.com/google/go-github/v74/github" ) // Fetch and lists all the public topics associated with the specified GitHub topic. diff --git a/example/verifyartifact/main.go b/example/verifyartifact/main.go index 67aa8374e12..91a8fe3a1c8 100644 --- a/example/verifyartifact/main.go +++ b/example/verifyartifact/main.go @@ -18,7 +18,7 @@ import ( "log" "os" - "github.com/google/go-github/v73/github" + "github.com/google/go-github/v74/github" "github.com/sigstore/sigstore-go/pkg/bundle" "github.com/sigstore/sigstore-go/pkg/root" "github.com/sigstore/sigstore-go/pkg/verify" diff --git a/github/doc.go b/github/doc.go index 2d7191cc389..fd83f899cfb 100644 --- a/github/doc.go +++ b/github/doc.go @@ -8,7 +8,7 @@ Package github provides a client for using the GitHub API. Usage: - import "github.com/google/go-github/v73/github" // with go modules enabled (GO111MODULE=on or outside GOPATH) + import "github.com/google/go-github/v74/github" // with go modules enabled (GO111MODULE=on or outside GOPATH) import "github.com/google/go-github/github" // with go modules disabled Construct a new GitHub client, then use the various services on the client to diff --git a/github/examples_test.go b/github/examples_test.go index 454ad8db539..525b0f03158 100644 --- a/github/examples_test.go +++ b/github/examples_test.go @@ -12,7 +12,7 @@ import ( "fmt" "log" - "github.com/google/go-github/v73/github" + "github.com/google/go-github/v74/github" ) func ExampleMarkdownService_Render() { diff --git a/github/github.go b/github/github.go index 481752c5cb9..bb81b00c104 100644 --- a/github/github.go +++ b/github/github.go @@ -29,7 +29,7 @@ import ( ) const ( - Version = "v73.0.0" + Version = "v74.0.0" defaultAPIVersion = "2022-11-28" defaultBaseURL = "https://api.github.com/" diff --git a/go.mod b/go.mod index 5c19858ca5a..971af60cb3f 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/google/go-github/v73 +module github.com/google/go-github/v74 go 1.23.0 diff --git a/test/fields/fields.go b/test/fields/fields.go index 07455cc5faa..c0b2eed7ba8 100644 --- a/test/fields/fields.go +++ b/test/fields/fields.go @@ -25,7 +25,7 @@ import ( "reflect" "strings" - "github.com/google/go-github/v73/github" + "github.com/google/go-github/v74/github" ) var ( diff --git a/test/integration/activity_test.go b/test/integration/activity_test.go index f0b9b705cbe..b2ddf79fdd1 100644 --- a/test/integration/activity_test.go +++ b/test/integration/activity_test.go @@ -11,7 +11,7 @@ import ( "context" "testing" - "github.com/google/go-github/v73/github" + "github.com/google/go-github/v74/github" ) const ( diff --git a/test/integration/authorizations_test.go b/test/integration/authorizations_test.go index da00b574ab7..9a1f397bffe 100644 --- a/test/integration/authorizations_test.go +++ b/test/integration/authorizations_test.go @@ -14,7 +14,7 @@ import ( "testing" "time" - "github.com/google/go-github/v73/github" + "github.com/google/go-github/v74/github" ) const msgEnvMissing = "Skipping test because the required environment variable (%v) is not present." diff --git a/test/integration/github_test.go b/test/integration/github_test.go index b48cc58db0a..593b8d285ce 100644 --- a/test/integration/github_test.go +++ b/test/integration/github_test.go @@ -14,7 +14,7 @@ import ( "net/http" "os" - "github.com/google/go-github/v73/github" + "github.com/google/go-github/v74/github" ) var ( diff --git a/test/integration/repos_test.go b/test/integration/repos_test.go index 925afa01a7c..656a8cdc2a7 100644 --- a/test/integration/repos_test.go +++ b/test/integration/repos_test.go @@ -14,7 +14,7 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/google/go-github/v73/github" + "github.com/google/go-github/v74/github" ) func TestRepositories_CRUD(t *testing.T) { diff --git a/test/integration/users_test.go b/test/integration/users_test.go index e15a54cdcbf..878b1026f9d 100644 --- a/test/integration/users_test.go +++ b/test/integration/users_test.go @@ -13,7 +13,7 @@ import ( "math/rand" "testing" - "github.com/google/go-github/v73/github" + "github.com/google/go-github/v74/github" ) func TestUsers_Get(t *testing.T) { diff --git a/tools/go.mod b/tools/go.mod index 76d8b25ed23..3087db7cd20 100644 --- a/tools/go.mod +++ b/tools/go.mod @@ -6,7 +6,7 @@ require ( github.com/alecthomas/kong v1.12.1 github.com/getkin/kin-openapi v0.132.0 github.com/google/go-cmp v0.7.0 - github.com/google/go-github/v73 v73.0.0 + github.com/google/go-github/v74 v74.0.0 golang.org/x/sync v0.16.0 gopkg.in/yaml.v3 v3.0.1 ) @@ -25,4 +25,4 @@ require ( ) // Use version at HEAD, not the latest published. -replace github.com/google/go-github/v73 => ../ +replace github.com/google/go-github/v74 => ../ diff --git a/tools/metadata/main.go b/tools/metadata/main.go index 2725db77610..6c4d49eda5a 100644 --- a/tools/metadata/main.go +++ b/tools/metadata/main.go @@ -16,7 +16,7 @@ import ( "path/filepath" "github.com/alecthomas/kong" - "github.com/google/go-github/v73/github" + "github.com/google/go-github/v74/github" ) var helpVars = kong.Vars{ diff --git a/tools/metadata/main_test.go b/tools/metadata/main_test.go index 173d11ab4f9..b617edc3640 100644 --- a/tools/metadata/main_test.go +++ b/tools/metadata/main_test.go @@ -23,7 +23,7 @@ import ( "github.com/alecthomas/kong" "github.com/getkin/kin-openapi/openapi3" "github.com/google/go-cmp/cmp" - "github.com/google/go-github/v73/github" + "github.com/google/go-github/v74/github" ) func TestUpdateGo(t *testing.T) { diff --git a/tools/metadata/metadata.go b/tools/metadata/metadata.go index a04c9921b26..35d90142931 100644 --- a/tools/metadata/metadata.go +++ b/tools/metadata/metadata.go @@ -24,7 +24,7 @@ import ( "strings" "sync" - "github.com/google/go-github/v73/github" + "github.com/google/go-github/v74/github" "gopkg.in/yaml.v3" ) diff --git a/tools/metadata/openapi.go b/tools/metadata/openapi.go index 3912c54393d..37f432669fe 100644 --- a/tools/metadata/openapi.go +++ b/tools/metadata/openapi.go @@ -14,7 +14,7 @@ import ( "strconv" "github.com/getkin/kin-openapi/openapi3" - "github.com/google/go-github/v73/github" + "github.com/google/go-github/v74/github" "golang.org/x/sync/errgroup" )