diff --git a/github/github-accessors.go b/github/github-accessors.go index 1be9493a37c..43bb7d0c687 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -15150,6 +15150,14 @@ func (p *PullRequestComment) GetStartSide() string { return *p.StartSide } +// GetSubjectType returns the SubjectType field if it's non-nil, zero value otherwise. +func (p *PullRequestComment) GetSubjectType() string { + if p == nil || p.SubjectType == nil { + return "" + } + return *p.SubjectType +} + // GetUpdatedAt returns the UpdatedAt field if it's non-nil, zero value otherwise. func (p *PullRequestComment) GetUpdatedAt() Timestamp { if p == nil || p.UpdatedAt == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 2235cc5e131..09c402ed73e 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -17669,6 +17669,16 @@ func TestPullRequestComment_GetStartSide(tt *testing.T) { p.GetStartSide() } +func TestPullRequestComment_GetSubjectType(tt *testing.T) { + var zeroValue string + p := &PullRequestComment{SubjectType: &zeroValue} + p.GetSubjectType() + p = &PullRequestComment{} + p.GetSubjectType() + p = nil + p.GetSubjectType() +} + func TestPullRequestComment_GetUpdatedAt(tt *testing.T) { var zeroValue Timestamp p := &PullRequestComment{UpdatedAt: &zeroValue} diff --git a/github/github-stringify_test.go b/github/github-stringify_test.go index 8a78fb02429..0ad7eefa342 100644 --- a/github/github-stringify_test.go +++ b/github/github-stringify_test.go @@ -1312,8 +1312,9 @@ func TestPullRequestComment_String(t *testing.T) { URL: String(""), HTMLURL: String(""), PullRequestURL: String(""), + SubjectType: String(""), } - want := `github.PullRequestComment{ID:0, NodeID:"", InReplyTo:0, Body:"", Path:"", DiffHunk:"", PullRequestReviewID:0, Position:0, OriginalPosition:0, StartLine:0, Line:0, OriginalLine:0, OriginalStartLine:0, Side:"", StartSide:"", CommitID:"", OriginalCommitID:"", User:github.User{}, Reactions:github.Reactions{}, CreatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, UpdatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, AuthorAssociation:"", URL:"", HTMLURL:"", PullRequestURL:""}` + want := `github.PullRequestComment{ID:0, NodeID:"", InReplyTo:0, Body:"", Path:"", DiffHunk:"", PullRequestReviewID:0, Position:0, OriginalPosition:0, StartLine:0, Line:0, OriginalLine:0, OriginalStartLine:0, Side:"", StartSide:"", CommitID:"", OriginalCommitID:"", User:github.User{}, Reactions:github.Reactions{}, CreatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, UpdatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, AuthorAssociation:"", URL:"", HTMLURL:"", PullRequestURL:"", SubjectType:""}` if got := v.String(); got != want { t.Errorf("PullRequestComment.String = %v, want %v", got, want) } diff --git a/github/pulls_comments.go b/github/pulls_comments.go index 1f6b726d85f..ea1cf45d1e8 100644 --- a/github/pulls_comments.go +++ b/github/pulls_comments.go @@ -41,6 +41,8 @@ type PullRequestComment struct { URL *string `json:"url,omitempty"` HTMLURL *string `json:"html_url,omitempty"` PullRequestURL *string `json:"pull_request_url,omitempty"` + // Can be one of: LINE, FILE from https://docs.github.com/en/rest/pulls/comments?apiVersion=2022-11-28#create-a-review-comment-for-a-pull-request + SubjectType *string `json:"subject_type,omitempty"` } func (p PullRequestComment) String() string {