Skip to content

Commit

Permalink
fix: positioning of comments on unmodified lines
Browse files Browse the repository at this point in the history
If there's a comment that needs to be added to a Github PR review,
and it's on an unmodified line, and pint can't find a modified line to put the comment on,
then just put the comment on the first changed line of the diff.
  • Loading branch information
wbh1 committed Jun 8, 2023
1 parent 7ca1053 commit 90b366f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion internal/reporter/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,13 @@ func reportToGitHubComment(headCommit string, rep Report) *github.PullRequestCom
msgPrefix,
rep.Problem.Text,
)),
Line: github.Int(reportLine),
}

if reportLine < 0 {
// If we couldn't find a nearby line to attach the comment to, put it on the first line of the diff
c.Position = github.Int(1)
} else {
c.Line = github.Int(reportLine)
}

return &c
Expand Down

0 comments on commit 90b366f

Please sign in to comment.