Skip to content

Commit eed4e3a

Browse files
authored
NIGH-153 Fix FilterComments Error (#41)
* fix bug caused by comments on outdated code * add outdated comment to test
1 parent 3b54d0b commit eed4e3a

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

internal/clients/diffreviewer/circleci/circleci_service.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -281,18 +281,18 @@ func filterExistingComments(comments []*github.PullRequestComment, existingComme
281281
existingCommentsMap := make(map[prComment]bool, len(existingComments))
282282
for _, ec := range existingComments {
283283
comment := prComment{
284-
Body: *ec.Body,
285-
Path: *ec.Path,
286-
Line: *ec.Line,
284+
Body: ec.GetBody(),
285+
Path: ec.GetPath(),
286+
Line: ec.GetLine(),
287287
}
288288
existingCommentsMap[comment] = true
289289
}
290290
filteredComments := make([]*github.PullRequestComment, 0, len(comments))
291291
for _, c := range comments {
292292
comment := prComment{
293-
Body: *c.Body,
294-
Path: *c.Path,
295-
Line: *c.Line,
293+
Body: c.GetBody(),
294+
Path: c.GetPath(),
295+
Line: c.GetLine(),
296296
}
297297
if _, ok := existingCommentsMap[comment]; !ok {
298298
filteredComments = append(filteredComments, c)

internal/clients/diffreviewer/circleci/circleci_service_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,11 @@ func (c *circleCiTestSuite) TestFilterExistingComments() {
444444
Path: &pathStrs[2],
445445
Line: &lineNums[2],
446446
},
447+
{
448+
Body: &bodyStrs[0],
449+
Path: &pathStrs[0],
450+
Line: nil,
451+
},
447452
}
448453
newComment1 := &github.PullRequestComment{
449454
Body: &bodyStrs[0],

0 commit comments

Comments
 (0)