Skip to content

Commit

Permalink
NIGH-153 Fix FilterComments Error (#41)
Browse files Browse the repository at this point in the history
* fix bug caused by comments on outdated code

* add outdated comment to test
  • Loading branch information
alan20854 authored Sep 3, 2020
1 parent 3b54d0b commit eed4e3a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
12 changes: 6 additions & 6 deletions internal/clients/diffreviewer/circleci/circleci_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,18 +281,18 @@ func filterExistingComments(comments []*github.PullRequestComment, existingComme
existingCommentsMap := make(map[prComment]bool, len(existingComments))
for _, ec := range existingComments {
comment := prComment{
Body: *ec.Body,
Path: *ec.Path,
Line: *ec.Line,
Body: ec.GetBody(),
Path: ec.GetPath(),
Line: ec.GetLine(),
}
existingCommentsMap[comment] = true
}
filteredComments := make([]*github.PullRequestComment, 0, len(comments))
for _, c := range comments {
comment := prComment{
Body: *c.Body,
Path: *c.Path,
Line: *c.Line,
Body: c.GetBody(),
Path: c.GetPath(),
Line: c.GetLine(),
}
if _, ok := existingCommentsMap[comment]; !ok {
filteredComments = append(filteredComments, c)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,11 @@ func (c *circleCiTestSuite) TestFilterExistingComments() {
Path: &pathStrs[2],
Line: &lineNums[2],
},
{
Body: &bodyStrs[0],
Path: &pathStrs[0],
Line: nil,
},
}
newComment1 := &github.PullRequestComment{
Body: &bodyStrs[0],
Expand Down

0 comments on commit eed4e3a

Please sign in to comment.