Skip to content

Commit

Permalink
github-check: Support range comments
Browse files Browse the repository at this point in the history
  • Loading branch information
haya14busa committed Jul 22, 2020
1 parent 8465dcb commit be61746
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions doghouse/server/doghouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,17 +233,27 @@ func (ch *Checker) summaryFindings(name string, checks []*reviewdog.FilteredChec

func (ch *Checker) toCheckRunAnnotation(c *reviewdog.FilteredCheck) *github.CheckRunAnnotation {
loc := c.Diagnostic.GetLocation()
endLine := loc.GetRange().GetEnd().GetLine()
startLine := int(loc.GetRange().GetStart().GetLine())
endLine := int(loc.GetRange().GetEnd().GetLine())
if endLine == 0 {
endLine = loc.GetRange().GetStart().GetLine()
endLine = startLine
}
a := &github.CheckRunAnnotation{
Path: github.String(loc.GetPath()),
StartLine: github.Int(int(loc.GetRange().GetStart().GetLine())),
EndLine: github.Int(int(endLine)),
StartLine: github.Int(startLine),
EndLine: github.Int(endLine),
AnnotationLevel: github.String(ch.annotationLevel(c.Diagnostic.Severity)),
Message: github.String(c.Diagnostic.GetMessage()),
}
// Annotations only support start_column and end_column on the same line.
if startLine == endLine {
if col := loc.GetRange().GetStart().GetColumn(); col != 0 {
a.StartColumn = github.Int(int(col))
}
if col := loc.GetRange().GetEnd().GetColumn(); col != 0 {
a.EndColumn = github.Int(int(col))
}
}
if ch.req.Name != "" {
a.Title = github.String(fmt.Sprintf("[%s] %s#L%d", ch.req.Name, loc.GetPath(), loc.GetRange().GetStart().GetLine()))
}
Expand Down

0 comments on commit be61746

Please sign in to comment.