diff --git a/cmd/review-bot/main.go b/cmd/review-bot/main.go index 1ee0380..cbcd10e 100644 --- a/cmd/review-bot/main.go +++ b/cmd/review-bot/main.go @@ -510,9 +510,9 @@ func main() { for _, f := range result.Findings { if f.File != "" && f.Line > 0 && diffRanges.Contains(f.File, f.Line) { inlineComments = append(inlineComments, vcsReviewComment{ - Path: f.File, - NewPosition: int64(f.Line), - Body: fmt.Sprintf("**[%s]** %s", f.Severity, f.Finding), + Path: f.File, + NewLine: int64(f.Line), + Body: fmt.Sprintf("**[%s]** %s", f.Severity, f.Finding), }) } } diff --git a/cmd/review-bot/vcs.go b/cmd/review-bot/vcs.go index 194dc50..4a98d52 100644 --- a/cmd/review-bot/vcs.go +++ b/cmd/review-bot/vcs.go @@ -83,9 +83,9 @@ type vcsCommitStatus struct { // vcsReviewComment is an inline review comment. type vcsReviewComment struct { - Path string - NewPosition int64 // Gitea: absolute line; GitHub: diff hunk position - Body string + Path string + NewLine int64 // absolute line number on the new (right) side of the diff, used by both Gitea and GitHub adapters + Body string } // vcsReview is a submitted PR review. @@ -176,7 +176,7 @@ func (a *giteaVCSAdapter) GetAllFilesInPath(ctx context.Context, owner, repo, pa func (a *giteaVCSAdapter) PostReview(ctx context.Context, owner, repo string, number int, event, body, commitID string, comments []vcsReviewComment) (*vcsReview, error) { gc := make([]gitea.ReviewComment, len(comments)) for i, c := range comments { - gc[i] = gitea.ReviewComment{Path: c.Path, NewPosition: c.NewPosition, Body: c.Body} + gc[i] = gitea.ReviewComment{Path: c.Path, NewPosition: c.NewLine, Body: c.Body} } r, err := a.c.PostReview(ctx, owner, repo, number, event, body, commitID, gc) if err != nil { @@ -311,14 +311,12 @@ func (a *githubVCSAdapter) GetAllFilesInPath(ctx context.Context, owner, repo, p func (a *githubVCSAdapter) PostReview(ctx context.Context, owner, repo string, number int, event, body, commitID string, comments []vcsReviewComment) (*vcsReview, error) { gc := make([]github.ReviewComment, len(comments)) for i, c := range comments { - // GitHub inline comments use diff hunk "position", not absolute line numbers. - // NewPosition from gitea diff parsing gives absolute line numbers, which - // will not match GitHub's position values. For initial GitHub support, we - // attach comments with Line+Side (absolute line on the RIGHT side) instead. + // GitHub inline comments use Line+Side (absolute line on the RIGHT side). + // NewLine from diff parsing gives absolute new-file line numbers. // Comments that cannot be mapped will be omitted (GitHub rejects invalid positions). gc[i] = github.ReviewComment{ Path: c.Path, - Line: c.NewPosition, + Line: c.NewLine, Side: "RIGHT", Body: c.Body, }