Skip to content

Commit

Permalink
github support multi-line comment
Browse files Browse the repository at this point in the history
  • Loading branch information
wangcheng committed Feb 19, 2024
1 parent 79410a6 commit 5edc4eb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
26 changes: 19 additions & 7 deletions github.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,25 @@ func buildPullRequestCommentBody(linterName string, lintErrs map[string][]linter
message := fmt.Sprintf("[%s] %s\n%s",
linterName, lintErr.Message, linters.CommentFooter)

comments = append(comments, &github.PullRequestComment{
Body: github.String(message),
Path: github.String(file),
Line: github.Int(lintErr.Line),
Side: github.String("RIGHT"),
CommitID: github.String(commitID),
})
if lintErr.Strat_line != 0 {
comments = append(comments, &github.PullRequestComment{
Body: github.String(message),
Path: github.String(file),
Line: github.Int(lintErr.Line),
StartLine: github.Int(lintErr.Strat_line),
StartSide: github.String("RIGHT"),
Side: github.String("RIGHT"),
CommitID: github.String(commitID),
})
} else {
comments = append(comments, &github.PullRequestComment{
Body: github.String(message),
Path: github.String(file),
Line: github.Int(lintErr.Line),
Side: github.String("RIGHT"),
CommitID: github.String(commitID),
})
}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions internal/linters/linters.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ type LinterOutput struct {
Column int
// Message is the staticcheck Message
Message string
//Strat_line required when using multi-line comments
StratLine int
}

// Agent knows necessary information from reviewbot.
Expand Down

0 comments on commit 5edc4eb

Please sign in to comment.