Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .custom-gcl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ plugins:
path: ./tools/extraneousnew
- module: "github.com/google/go-github/v84/tools/fmtpercentv"
path: ./tools/fmtpercentv
- module: "github.com/google/go-github/v84/tools/redundantptr"
path: ./tools/redundantptr
- module: "github.com/google/go-github/v84/tools/sliceofpointers"
path: ./tools/sliceofpointers
- module: "github.com/google/go-github/v84/tools/structfield"
Expand Down
5 changes: 5 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ linters:
- nolintlint
- paralleltest
- perfsprint
- redundantptr
- revive
- sliceofpointers
- staticcheck
Expand Down Expand Up @@ -193,6 +194,10 @@ linters:
type: module
description: Reports usage of %d or %s in format strings.
original-url: github.com/google/go-github/v84/tools/fmtpercentv
redundantptr:
type: module
description: Reports github.Ptr(x) calls that can be replaced with &x.
original-url: github.com/google/go-github/v84/tools/redundantptr
sliceofpointers:
type: module
description: Reports usage of []*string and slices of structs without pointers.
Expand Down
2 changes: 1 addition & 1 deletion example/commitpr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func getTree(ref *github.Reference) (tree *github.Tree, err error) {
if err != nil {
return nil, err
}
entries = append(entries, &github.TreeEntry{Path: github.Ptr(file), Type: github.Ptr("blob"), Content: github.Ptr(string(content)), Mode: github.Ptr("100644")})
entries = append(entries, &github.TreeEntry{Path: &file, Type: github.Ptr("blob"), Content: github.Ptr(string(content)), Mode: github.Ptr("100644")})
}

tree, _, err = client.Git.CreateTree(ctx, *sourceOwner, *sourceRepo, *ref.Object.SHA, entries)
Expand Down
18 changes: 6 additions & 12 deletions github/actions_hosted_runners_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ func TestActionsService_ListHostedRunners(t *testing.T) {
t.Errorf("Actions.ListHostedRunners returned error: %v", err)
}

lastActiveOn := Timestamp{time.Date(2023, 4, 26, 15, 23, 37, 0, time.UTC)}

want := &HostedRunners{
TotalCount: 2,
Runners: []*HostedRunner{
Expand Down Expand Up @@ -111,7 +109,7 @@ func TestActionsService_ListHostedRunners(t *testing.T) {
Length: 31,
},
},
LastActiveOn: Ptr(lastActiveOn),
LastActiveOn: Ptr(Timestamp{time.Date(2023, 4, 26, 15, 23, 37, 0, time.UTC)}),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please revert all changes to github/actions_hosted_runners_test.go as I would consider this a regression in terms of readability. Having a single lastActiveOn variable is much easier to read and understand than having to look at each argument to see if the timestamps are the same and then trying to figure out why a single value was not OK to use here.

If you have to add exceptions to your linter, then I think that is what needs to be done.

},
{
ID: Ptr(int64(7)),
Expand All @@ -132,7 +130,7 @@ func TestActionsService_ListHostedRunners(t *testing.T) {
MaximumRunners: Ptr(int64(20)),
PublicIPEnabled: Ptr(false),
PublicIPs: []*HostedRunnerPublicIP{},
LastActiveOn: Ptr(lastActiveOn),
LastActiveOn: Ptr(Timestamp{time.Date(2023, 4, 26, 15, 23, 37, 0, time.UTC)}),
},
},
}
Expand Down Expand Up @@ -210,7 +208,6 @@ func TestActionsService_CreateHostedRunner(t *testing.T) {
t.Errorf("Actions.CreateHostedRunner returned error: %v", err)
}

lastActiveOn := Timestamp{time.Date(2023, 4, 26, 15, 23, 37, 0, time.UTC)}
want := &HostedRunner{
ID: Ptr(int64(5)),
Name: Ptr("My hosted ubuntu runner"),
Expand All @@ -236,7 +233,7 @@ func TestActionsService_CreateHostedRunner(t *testing.T) {
Length: 31,
},
},
LastActiveOn: Ptr(lastActiveOn),
LastActiveOn: Ptr(Timestamp{time.Date(2023, 4, 26, 15, 23, 37, 0, time.UTC)}),
}

if !cmp.Equal(hostedRunner, want) {
Expand Down Expand Up @@ -626,7 +623,6 @@ func TestActionsService_GetHostedRunner(t *testing.T) {
t.Errorf("Actions.GetHostedRunner returned error: %v", err)
}

lastActiveOn := Timestamp{time.Date(2023, 4, 26, 15, 23, 37, 0, time.UTC)}
want := &HostedRunner{
ID: Ptr(int64(5)),
Name: Ptr("My hosted ubuntu runner"),
Expand All @@ -652,7 +648,7 @@ func TestActionsService_GetHostedRunner(t *testing.T) {
Length: 31,
},
},
LastActiveOn: Ptr(lastActiveOn),
LastActiveOn: Ptr(Timestamp{time.Date(2023, 4, 26, 15, 23, 37, 0, time.UTC)}),
}

if !cmp.Equal(hostedRunner, want) {
Expand Down Expand Up @@ -722,7 +718,6 @@ func TestActionsService_UpdateHostedRunner(t *testing.T) {
t.Errorf("Actions.UpdateHostedRunner returned error: %v", err)
}

lastActiveOn := Timestamp{time.Date(2023, 4, 26, 15, 23, 37, 0, time.UTC)}
want := &HostedRunner{
ID: Ptr(int64(5)),
Name: Ptr("My hosted ubuntu runner"),
Expand All @@ -748,7 +743,7 @@ func TestActionsService_UpdateHostedRunner(t *testing.T) {
Length: 31,
},
},
LastActiveOn: Ptr(lastActiveOn),
LastActiveOn: Ptr(Timestamp{time.Date(2023, 4, 26, 15, 23, 37, 0, time.UTC)}),
}

if !cmp.Equal(hostedRunner, want) {
Expand Down Expand Up @@ -811,7 +806,6 @@ func TestActionsService_DeleteHostedRunner(t *testing.T) {
t.Errorf("Actions.GetHostedRunner returned error: %v", err)
}

lastActiveOn := Timestamp{time.Date(2023, 4, 26, 15, 23, 37, 0, time.UTC)}
want := &HostedRunner{
ID: Ptr(int64(5)),
Name: Ptr("My hosted ubuntu runner"),
Expand All @@ -837,7 +831,7 @@ func TestActionsService_DeleteHostedRunner(t *testing.T) {
Length: 31,
},
},
LastActiveOn: Ptr(lastActiveOn),
LastActiveOn: Ptr(Timestamp{time.Date(2023, 4, 26, 15, 23, 37, 0, time.UTC)}),
}

if !cmp.Equal(hostedRunner, want) {
Expand Down
6 changes: 2 additions & 4 deletions github/actions_runner_groups_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,8 +483,6 @@ func TestActionsService_ListRunnerGroupHostedRunners(t *testing.T) {
t.Errorf("Actions.ListRunnerGroupHostedRunners returned error: %v", err)
}

lastActiveOn := Timestamp{time.Date(2023, 4, 26, 15, 23, 37, 0, time.UTC)}

want := &HostedRunners{
TotalCount: 2,
Runners: []*HostedRunner{
Expand Down Expand Up @@ -513,7 +511,7 @@ func TestActionsService_ListRunnerGroupHostedRunners(t *testing.T) {
Length: 31,
},
},
LastActiveOn: Ptr(lastActiveOn),
LastActiveOn: Ptr(Timestamp{time.Date(2023, 4, 26, 15, 23, 37, 0, time.UTC)}),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same here

},
{
ID: Ptr(int64(7)),
Expand All @@ -534,7 +532,7 @@ func TestActionsService_ListRunnerGroupHostedRunners(t *testing.T) {
MaximumRunners: Ptr(int64(20)),
PublicIPEnabled: Ptr(false),
PublicIPs: []*HostedRunnerPublicIP{},
LastActiveOn: Ptr(lastActiveOn),
LastActiveOn: Ptr(Timestamp{time.Date(2023, 4, 26, 15, 23, 37, 0, time.UTC)}),
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion github/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ func (s *AppsService) CreateInstallationTokenListRepos(ctx context.Context, id i
//meta:operation POST /repos/{owner}/{repo}/content_references/{content_reference_id}/attachments
func (s *AppsService) CreateAttachment(ctx context.Context, contentReferenceID int64, title, body string) (*Attachment, *Response, error) {
u := fmt.Sprintf("content_references/%v/attachments", contentReferenceID)
payload := &Attachment{Title: Ptr(title), Body: Ptr(body)}
payload := &Attachment{Title: &title, Body: &body}
req, err := s.client.NewRequest("POST", u, payload)
if err != nil {
return nil, nil, err
Expand Down
18 changes: 6 additions & 12 deletions github/enterprise_actions_hosted_runners_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ func TestEnterpriseService_ListHostedRunners(t *testing.T) {
t.Errorf("Enterprise.ListHostedRunners returned error: %v", err)
}

lastActiveOn := Timestamp{time.Date(2023, 4, 26, 15, 23, 37, 0, time.UTC)}

want := &HostedRunners{
TotalCount: 2,
Runners: []*HostedRunner{
Expand Down Expand Up @@ -111,7 +109,7 @@ func TestEnterpriseService_ListHostedRunners(t *testing.T) {
Length: 31,
},
},
LastActiveOn: Ptr(lastActiveOn),
LastActiveOn: Ptr(Timestamp{time.Date(2023, 4, 26, 15, 23, 37, 0, time.UTC)}),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same here

},
{
ID: Ptr(int64(7)),
Expand All @@ -132,7 +130,7 @@ func TestEnterpriseService_ListHostedRunners(t *testing.T) {
MaximumRunners: Ptr(int64(20)),
PublicIPEnabled: Ptr(false),
PublicIPs: []*HostedRunnerPublicIP{},
LastActiveOn: Ptr(lastActiveOn),
LastActiveOn: Ptr(Timestamp{time.Date(2023, 4, 26, 15, 23, 37, 0, time.UTC)}),
},
},
}
Expand Down Expand Up @@ -209,7 +207,6 @@ func TestEnterpriseService_CreateHostedRunner(t *testing.T) {
t.Errorf("Enterprise.CreateHostedRunner returned error: %v", err)
}

lastActiveOn := Timestamp{time.Date(2023, 4, 26, 15, 23, 37, 0, time.UTC)}
want := &HostedRunner{
ID: Ptr(int64(5)),
Name: Ptr("My hosted ubuntu runner"),
Expand All @@ -235,7 +232,7 @@ func TestEnterpriseService_CreateHostedRunner(t *testing.T) {
Length: 31,
},
},
LastActiveOn: Ptr(lastActiveOn),
LastActiveOn: Ptr(Timestamp{time.Date(2023, 4, 26, 15, 23, 37, 0, time.UTC)}),
}

if !cmp.Equal(hostedRunner, want) {
Expand Down Expand Up @@ -624,7 +621,6 @@ func TestEnterpriseService_GetHostedRunner(t *testing.T) {
t.Errorf("Enterprise.GetHostedRunner returned error: %v", err)
}

lastActiveOn := Timestamp{time.Date(2023, 4, 26, 15, 23, 37, 0, time.UTC)}
want := &HostedRunner{
ID: Ptr(int64(5)),
Name: Ptr("My hosted ubuntu runner"),
Expand All @@ -650,7 +646,7 @@ func TestEnterpriseService_GetHostedRunner(t *testing.T) {
Length: 31,
},
},
LastActiveOn: Ptr(lastActiveOn),
LastActiveOn: Ptr(Timestamp{time.Date(2023, 4, 26, 15, 23, 37, 0, time.UTC)}),
}

if !cmp.Equal(hostedRunner, want) {
Expand Down Expand Up @@ -721,7 +717,6 @@ func TestEnterpriseService_UpdateHostedRunner(t *testing.T) {
t.Errorf("Enterprise.UpdateHostedRunner returned error: %v", err)
}

lastActiveOn := Timestamp{time.Date(2023, 4, 26, 15, 23, 37, 0, time.UTC)}
want := &HostedRunner{
ID: Ptr(int64(5)),
Name: Ptr("My hosted ubuntu runner"),
Expand All @@ -747,7 +742,7 @@ func TestEnterpriseService_UpdateHostedRunner(t *testing.T) {
Length: 31,
},
},
LastActiveOn: Ptr(lastActiveOn),
LastActiveOn: Ptr(Timestamp{time.Date(2023, 4, 26, 15, 23, 37, 0, time.UTC)}),
}

if !cmp.Equal(hostedRunner, want) {
Expand Down Expand Up @@ -810,7 +805,6 @@ func TestEnterpriseService_DeleteHostedRunner(t *testing.T) {
t.Errorf("Enterprise.GetHostedRunner returned error: %v", err)
}

lastActiveOn := Timestamp{time.Date(2023, 4, 26, 15, 23, 37, 0, time.UTC)}
want := &HostedRunner{
ID: Ptr(int64(5)),
Name: Ptr("My hosted ubuntu runner"),
Expand All @@ -836,7 +830,7 @@ func TestEnterpriseService_DeleteHostedRunner(t *testing.T) {
Length: 31,
},
},
LastActiveOn: Ptr(lastActiveOn),
LastActiveOn: Ptr(Timestamp{time.Date(2023, 4, 26, 15, 23, 37, 0, time.UTC)}),
}

if !cmp.Equal(hostedRunner, want) {
Expand Down
6 changes: 3 additions & 3 deletions github/git_commits_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func TestGitService_CreateSignedCommit(t *testing.T) {
Tree: &Tree{SHA: Ptr("t")},
Parents: []*Commit{{SHA: Ptr("p")}},
Verification: &SignatureVerification{
Signature: Ptr(signature),
Signature: &signature,
},
}

Expand All @@ -249,7 +249,7 @@ func TestGitService_CreateSignedCommit(t *testing.T) {
Message: input.Message,
Tree: Ptr("t"),
Parents: []string{"p"},
Signature: Ptr(signature),
Signature: &signature,
}
if !cmp.Equal(v, want) {
t.Errorf("Request body = %+v, want %+v", v, want)
Expand Down Expand Up @@ -336,7 +336,7 @@ Commit Message.`
fmt.Fprintf(w, `{"sha":"%v"}`, sha)
})
ctx := t.Context()
wantCommit := &Commit{SHA: Ptr(sha)}
wantCommit := &Commit{SHA: &sha}
opts := CreateCommitOptions{Signer: mockSigner(t, signature, nil, wantMessage)}
commit, _, err := client.Git.CreateCommit(ctx, "o", "r", input, &opts)
assertNilError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion github/interactions_orgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (s *InteractionsService) GetRestrictionsForOrg(ctx context.Context, organiz
func (s *InteractionsService) UpdateRestrictionsForOrg(ctx context.Context, organization, limit string) (*InteractionRestriction, *Response, error) {
u := fmt.Sprintf("orgs/%v/interaction-limits", organization)

interaction := &InteractionRestriction{Limit: Ptr(limit)}
interaction := &InteractionRestriction{Limit: &limit}

req, err := s.client.NewRequest("PUT", u, interaction)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion github/interactions_repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (s *InteractionsService) GetRestrictionsForRepo(ctx context.Context, owner,
func (s *InteractionsService) UpdateRestrictionsForRepo(ctx context.Context, owner, repo, limit string) (*InteractionRestriction, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/interaction-limits", owner, repo)

interaction := &InteractionRestriction{Limit: Ptr(limit)}
interaction := &InteractionRestriction{Limit: &limit}

req, err := s.client.NewRequest("PUT", u, interaction)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions github/markdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ type markdownRenderRequest struct {
//
//meta:operation POST /markdown
func (s *MarkdownService) Render(ctx context.Context, text string, opts *MarkdownOptions) (string, *Response, error) {
request := &markdownRenderRequest{Text: Ptr(text)}
request := &markdownRenderRequest{Text: &text}
if opts != nil {
if opts.Mode != "" {
request.Mode = Ptr(opts.Mode)
request.Mode = &opts.Mode
}
if opts.Context != "" {
request.Context = Ptr(opts.Context)
request.Context = &opts.Context
}
}

Expand Down
6 changes: 3 additions & 3 deletions github/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ func (s *MigrationService) StartMigration(ctx context.Context, org string, repos

body := &startMigration{Repositories: repos}
if opts != nil {
body.LockRepositories = Ptr(opts.LockRepositories)
body.ExcludeAttachments = Ptr(opts.ExcludeAttachments)
body.ExcludeReleases = Ptr(opts.ExcludeReleases)
body.LockRepositories = &opts.LockRepositories
body.ExcludeAttachments = &opts.ExcludeAttachments
body.ExcludeReleases = &opts.ExcludeReleases
body.Exclude = append(body.Exclude, opts.Exclude...)
}

Expand Down
4 changes: 2 additions & 2 deletions github/migrations_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ func (s *MigrationService) StartUserMigration(ctx context.Context, repos []strin

body := &startUserMigration{Repositories: repos}
if opts != nil {
body.LockRepositories = Ptr(opts.LockRepositories)
body.ExcludeAttachments = Ptr(opts.ExcludeAttachments)
body.LockRepositories = &opts.LockRepositories
body.ExcludeAttachments = &opts.ExcludeAttachments
}

req, err := s.client.NewRequest("POST", u, body)
Expand Down
Loading
Loading