Skip to content

Commit fd74cf9

Browse files
Tyler SullensJoeColeman95
andauthored
handle edge cases with comments
Co-authored-by: Joe Coleman <107399878+JoeColeman95@users.noreply.github.com>
1 parent 3912b00 commit fd74cf9

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

internal/issue/comment/comment.go

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,31 @@ func (c *Commenter) FindExistingComment(ctx context.Context, owner string, repo
8181
return nil, err
8282
}
8383

84-
comments, _, err := c.client.ListComments(ctx, owner, repo, numberConverted, nil)
85-
if err != nil {
86-
return nil, err
84+
opt := &github.IssueListCommentsOptions{
85+
ListOptions: github.ListOptions{PerPage: 100},
8786
}
88-
for _, comment := range comments {
89-
if comment.Body != nil && strings.Contains(*comment.Body, c.messageId) {
90-
return comment, nil
87+
for {
88+
comments, resp, err := c.client.ListComments(ctx, owner, repo, numberConverted, opt)
89+
if err != nil {
90+
return nil, err
91+
}
92+
for _, comment := range comments {
93+
if comment.Body != nil && strings.Contains(*comment.Body, c.messageId) {
94+
return comment, nil
95+
}
9196
}
97+
if resp.NextPage == 0 {
98+
break
99+
}
100+
opt.Page = resp.NextPage
92101
}
93102
return nil, nil
94103
}
95104

96105
func (c *Commenter) MatchBody(ctx context.Context, comment *github.IssueComment, message string) bool {
97106
// Match for exact body content
107+
if comment == nil || comment.Body == nil {
108+
return false
109+
}
98110
return c.formatBody(message) == *comment.Body
99111
}

0 commit comments

Comments
 (0)