From f2a9c9c58ce1bfe5d8c7c7b40d314fc66e495ee9 Mon Sep 17 00:00:00 2001 From: Alexis Couvreur Date: Wed, 18 Dec 2024 04:24:02 -0500 Subject: [PATCH] fix!: remove `Stats` field from `Commit` struct This field appears to never be populated throughout the codebase. Closes #3394 --- github/git_commits.go | 1 - github/git_commits_test.go | 10 ---------- github/github-accessors.go | 8 -------- github/github-accessors_test.go | 8 -------- github/github-stringify_test.go | 3 +-- github/repos_commits_test.go | 10 ---------- github/repos_contents_test.go | 10 ---------- 7 files changed, 1 insertion(+), 49 deletions(-) diff --git a/github/git_commits.go b/github/git_commits.go index fdb3d26ceab..d7ed3ecbec5 100644 --- a/github/git_commits.go +++ b/github/git_commits.go @@ -49,7 +49,6 @@ type Commit struct { Message *string `json:"message,omitempty"` Tree *Tree `json:"tree,omitempty"` Parents []*Commit `json:"parents,omitempty"` - Stats *CommitStats `json:"stats,omitempty"` HTMLURL *string `json:"html_url,omitempty"` URL *string `json:"url,omitempty"` Verification *SignatureVerification `json:"verification,omitempty"` diff --git a/github/git_commits_test.go b/github/git_commits_test.go index a58a4d98a1f..f0ad44b6a64 100644 --- a/github/git_commits_test.go +++ b/github/git_commits_test.go @@ -71,11 +71,6 @@ func TestCommit_Marshal(t *testing.T) { Truncated: Ptr(false), }, Parents: nil, - Stats: &CommitStats{ - Additions: Ptr(1), - Deletions: Ptr(1), - Total: Ptr(1), - }, HTMLURL: Ptr("h"), URL: Ptr("u"), Verification: &SignatureVerification{ @@ -118,11 +113,6 @@ func TestCommit_Marshal(t *testing.T) { ], "truncated": false }, - "stats": { - "additions": 1, - "deletions": 1, - "total": 1 - }, "html_url": "h", "url": "u", "verification": { diff --git a/github/github-accessors.go b/github/github-accessors.go index 2d17414064f..0800c02c6c4 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -3542,14 +3542,6 @@ func (c *Commit) GetSHA() string { return *c.SHA } -// GetStats returns the Stats field. -func (c *Commit) GetStats() *CommitStats { - if c == nil { - return nil - } - return c.Stats -} - // GetTree returns the Tree field. func (c *Commit) GetTree() *Tree { if c == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 3cf970d33f2..4b5c9dcb263 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -4614,14 +4614,6 @@ func TestCommit_GetSHA(tt *testing.T) { c.GetSHA() } -func TestCommit_GetStats(tt *testing.T) { - tt.Parallel() - c := &Commit{} - c.GetStats() - c = nil - c.GetStats() -} - func TestCommit_GetTree(tt *testing.T) { tt.Parallel() c := &Commit{} diff --git a/github/github-stringify_test.go b/github/github-stringify_test.go index e9d8f29d061..6fda6a907c7 100644 --- a/github/github-stringify_test.go +++ b/github/github-stringify_test.go @@ -283,14 +283,13 @@ func TestCommit_String(t *testing.T) { Committer: &CommitAuthor{}, Message: Ptr(""), Tree: &Tree{}, - Stats: &CommitStats{}, HTMLURL: Ptr(""), URL: Ptr(""), Verification: &SignatureVerification{}, NodeID: Ptr(""), CommentCount: Ptr(0), } - want := `github.Commit{SHA:"", Author:github.CommitAuthor{}, Committer:github.CommitAuthor{}, Message:"", Tree:github.Tree{}, Stats:github.CommitStats{}, HTMLURL:"", URL:"", Verification:github.SignatureVerification{}, NodeID:"", CommentCount:0}` + want := `github.Commit{SHA:"", Author:github.CommitAuthor{}, Committer:github.CommitAuthor{}, Message:"", Tree:github.Tree{}, HTMLURL:"", URL:"", Verification:github.SignatureVerification{}, NodeID:"", CommentCount:0}` if got := v.String(); got != want { t.Errorf("Commit.String = %v, want %v", got, want) } diff --git a/github/repos_commits_test.go b/github/repos_commits_test.go index fb99a75a614..eba7e7520ad 100644 --- a/github/repos_commits_test.go +++ b/github/repos_commits_test.go @@ -714,11 +714,6 @@ func TestBranchCommit_Marshal(t *testing.T) { Truncated: Ptr(false), }, Parents: nil, - Stats: &CommitStats{ - Additions: Ptr(1), - Deletions: Ptr(1), - Total: Ptr(1), - }, HTMLURL: Ptr("h"), URL: Ptr("u"), Verification: &SignatureVerification{ @@ -765,11 +760,6 @@ func TestBranchCommit_Marshal(t *testing.T) { ], "truncated": false }, - "stats": { - "additions": 1, - "deletions": 1, - "total": 1 - }, "html_url": "h", "url": "u", "verification": { diff --git a/github/repos_contents_test.go b/github/repos_contents_test.go index b50e32fc30c..e75a00e6d5c 100644 --- a/github/repos_contents_test.go +++ b/github/repos_contents_test.go @@ -894,11 +894,6 @@ func TestRepositoryContentResponse_Marshal(t *testing.T) { Truncated: Ptr(false), }, Parents: nil, - Stats: &CommitStats{ - Additions: Ptr(1), - Deletions: Ptr(1), - Total: Ptr(1), - }, HTMLURL: Ptr("h"), URL: Ptr("u"), Verification: &SignatureVerification{ @@ -958,11 +953,6 @@ func TestRepositoryContentResponse_Marshal(t *testing.T) { ], "truncated": false }, - "stats": { - "additions": 1, - "deletions": 1, - "total": 1 - }, "html_url": "h", "url": "u", "verification": {