Skip to content

Commit

Permalink
github-check: Output end line in annotation title.
Browse files Browse the repository at this point in the history
  • Loading branch information
haya14busa committed Jul 22, 2020
1 parent 6f8f74a commit cf9b48c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions doghouse/server/doghouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,16 @@ func (ch *Checker) toCheckRunAnnotation(c *reviewdog.FilteredCheck) *github.Chec
a.EndColumn = github.Int(int(e))
}
}
if ch.req.Name != "" {
a.Title = github.String(fmt.Sprintf("[%s] %s#L%d", ch.req.Name, loc.GetPath(), loc.GetRange().GetStart().GetLine()))
toolName := c.Diagnostic.GetSource().GetName()
if toolName == "" {
toolName = ch.req.Name
}
if toolName != "" {
line := fmt.Sprintf("L%d", startLine)
if startLine < endLine {
line += fmt.Sprintf("-L%d", endLine)
}
a.Title = github.String(fmt.Sprintf("[%s] %s#%s", toolName, loc.GetPath(), line))
}
if s := strings.Join(c.Lines, "\n"); s != "" {
a.RawDetails = github.String(s)
Expand Down
4 changes: 2 additions & 2 deletions doghouse/server/doghouse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,15 @@ func TestCheck_OK(t *testing.T) {
EndLine: github.Int(3),
AnnotationLevel: github.String("warning"),
Message: github.String("test multiline"),
Title: github.String("[haya14busa-linter] sample.new.txt#L2"),
Title: github.String("[haya14busa-linter] sample.new.txt#L2-L3"),
},
{
Path: github.String("sample.new.txt"),
StartLine: github.Int(2),
EndLine: github.Int(3),
AnnotationLevel: github.String("warning"),
Message: github.String("test multiline with column"),
Title: github.String("[haya14busa-linter] sample.new.txt#L2"),
Title: github.String("[haya14busa-linter] sample.new.txt#L2-L3"),
},
{
Path: github.String("sample.new.txt"),
Expand Down

0 comments on commit cf9b48c

Please sign in to comment.