From 90b366f51aa17a3f3c814fa7362a3ed7ff1adfe7 Mon Sep 17 00:00:00 2001 From: Will Hegedus Date: Thu, 8 Jun 2023 17:19:23 -0400 Subject: [PATCH] fix: positioning of comments on unmodified lines 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. --- internal/reporter/github.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/reporter/github.go b/internal/reporter/github.go index 913a5851..a044f61c 100644 --- a/internal/reporter/github.go +++ b/internal/reporter/github.go @@ -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