Skip to content

Commit c969533

Browse files
authored
Fix GitHub delete review comments (#494)
1 parent 84d8737 commit c969533

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ require (
77
github.com/golang/mock v1.6.0
88
github.com/google/go-github/v45 v45.2.0
99
github.com/jfrog/build-info-go v1.9.10
10-
github.com/jfrog/froggit-go v1.14.0
10+
github.com/jfrog/froggit-go v1.14.1
1111
github.com/jfrog/gofrog v1.3.0
1212
github.com/jfrog/jfrog-cli-core/v2 v2.42.0
1313
github.com/jfrog/jfrog-client-go v1.32.1

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -880,8 +880,8 @@ github.com/jedib0t/go-pretty/v6 v6.4.7 h1:lwiTJr1DEkAgzljsUsORmWsVn5MQjt1BPJdPCt
880880
github.com/jedib0t/go-pretty/v6 v6.4.7/go.mod h1:Ndk3ase2CkQbXLLNf5QDHoYb6J9WtVfmHZu9n8rk2xs=
881881
github.com/jfrog/build-info-go v1.9.10 h1:uXnDLVxpqxoAMpXcki00QaBB+M2BoGMMpHODPkmmYOY=
882882
github.com/jfrog/build-info-go v1.9.10/go.mod h1:ujJ8XQZMdT2tMkLSMJNyDd1pCY+duwHdjV+9or9FLIg=
883-
github.com/jfrog/froggit-go v1.14.0 h1:WdbCgar/zMrmq5EIremVosLEbxEsOcpTtyhyeYZPbNE=
884-
github.com/jfrog/froggit-go v1.14.0/go.mod h1:0jRAaZZusaFFnITosmx6CA60SKryuoaCasJyUrP/c1s=
883+
github.com/jfrog/froggit-go v1.14.1 h1:cmQUHvmoTDnEihh3IyPgGgjkUsIYiRo9M1YpDfPHfr8=
884+
github.com/jfrog/froggit-go v1.14.1/go.mod h1:0jRAaZZusaFFnITosmx6CA60SKryuoaCasJyUrP/c1s=
885885
github.com/jfrog/gofrog v1.3.0 h1:o4zgsBZE4QyDbz2M7D4K6fXPTBJht+8lE87mS9bw7Gk=
886886
github.com/jfrog/gofrog v1.3.0/go.mod h1:IFMc+V/yf7rA5WZ74CSbXe+Lgf0iApEQLxRZVzKRUR0=
887887
github.com/jfrog/jfrog-cli-core/v2 v2.42.0 h1:bwSYjdwLSNNwVB0PDZyQ8HYC7LL+2hInQ1I69UIwSO8=

utils/reviewcomment.go

+11-9
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,18 @@ func AddReviewComments(repo *Repository, pullRequestID int, client vcsclient.Vcs
3737
err = errors.New("couldn't delete pull request comment: " + err.Error())
3838
return
3939
}
40-
// Add review comments for the given data
4140
commentsToAdd := getNewReviewComments(repo, vulnerabilitiesRows, iacIssues, sastIssues)
42-
if len(commentsToAdd) > 0 {
43-
for _, comment := range commentsToAdd {
44-
if e := client.AddPullRequestReviewComments(context.Background(), repo.RepoOwner, repo.RepoName, pullRequestID, comment.CommentInfo); e != nil {
45-
log.Debug("couldn't add pull request review comment, fallback to regular comment: " + e.Error())
46-
if err = client.AddPullRequestComment(context.Background(), repo.RepoOwner, repo.RepoName, getRegularCommentContent(comment), pullRequestID); err != nil {
47-
err = errors.New("couldn't add pull request comment, fallback to comment: " + err.Error())
48-
return
49-
}
41+
if len(commentsToAdd) == 0 {
42+
return
43+
}
44+
// Add review comments for the given data
45+
for _, comment := range commentsToAdd {
46+
log.Debug("creating a review comment for", comment.Type, comment.Location.File, comment.Location.StartLine, comment.Location.StartColumn)
47+
if e := client.AddPullRequestReviewComments(context.Background(), repo.RepoOwner, repo.RepoName, pullRequestID, comment.CommentInfo); e != nil {
48+
log.Debug("couldn't add pull request review comment, fallback to regular comment: " + e.Error())
49+
if err = client.AddPullRequestComment(context.Background(), repo.RepoOwner, repo.RepoName, getRegularCommentContent(comment), pullRequestID); err != nil {
50+
err = errors.New("couldn't add pull request comment, fallback to comment: " + err.Error())
51+
return
5052
}
5153
}
5254
}

0 commit comments

Comments
 (0)