Skip to content

Commit

Permalink
service/commentutil: rename CommentBody to MarkdownComment
Browse files Browse the repository at this point in the history
  • Loading branch information
haya14busa committed Jul 26, 2020
1 parent 6bc2b59 commit 3a980f8
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions service/commentutil/commentutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ func (p PostedComments) DebugLog() {
// BodyPrefix is prefix text of comment body.
const BodyPrefix = `<sub>reported by [reviewdog](https://github.com/reviewdog/reviewdog) :dog:</sub><br>`

// CommentBody creates comment body text.
func CommentBody(c *reviewdog.Comment) string {
// MarkdownComment creates comment body markdown .
func MarkdownComment(c *reviewdog.Comment) string {
tool := ""
if c.ToolName != "" {
tool = fmt.Sprintf("**[%s]** ", c.ToolName)
Expand Down
2 changes: 1 addition & 1 deletion service/commentutil/commentutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestCommentBody(t *testing.T) {
},
}
for _, tt := range tests {
if got := CommentBody(tt.in); got != strings.Trim(tt.want, "\n") {
if got := MarkdownComment(tt.in); got != strings.Trim(tt.want, "\n") {
t.Errorf("got unexpected comment.\ngot:\n%s\nwant:\n%s", got, tt.want)
}
}
Expand Down
2 changes: 1 addition & 1 deletion service/github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ func listAllPullRequestsComments(ctx context.Context, cli *github.Client,
}

func buildBody(c *reviewdog.Comment) string {
cbody := commentutil.CommentBody(c)
cbody := commentutil.MarkdownComment(c)
if suggestion := buildSuggestions(c); suggestion != "" {
cbody += "\n" + suggestion
}
Expand Down
2 changes: 1 addition & 1 deletion service/gitlab/gitlab_mr_commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (g *GitLabMergeRequestCommitCommenter) postCommentsForEach(ctx context.Cont
c := c
loc := c.Result.Diagnostic.GetLocation()
lnum := int(loc.GetRange().GetStart().GetLine())
body := commentutil.CommentBody(c)
body := commentutil.MarkdownComment(c)
if !c.Result.InDiffFile || lnum == 0 || g.postedcs.IsPosted(c, lnum, body) {
continue
}
Expand Down
2 changes: 1 addition & 1 deletion service/gitlab/gitlab_mr_discussion.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (g *GitLabMergeRequestDiscussionCommenter) postCommentsForEach(ctx context.
c := c
loc := c.Result.Diagnostic.GetLocation()
lnum := int(loc.GetRange().GetStart().GetLine())
body := commentutil.CommentBody(c)
body := commentutil.MarkdownComment(c)
if !c.Result.InDiffFile || lnum == 0 || postedcs.IsPosted(c, lnum, body) {
continue
}
Expand Down
10 changes: 5 additions & 5 deletions service/gitlab/gitlab_mr_discussion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func TestGitLabMergeRequestDiscussionCommenter_Post_Flush_review_api(t *testing.
{
Notes: []*gitlab.Note{
{
Body: commentutil.CommentBody(alreadyCommented1),
Body: commentutil.MarkdownComment(alreadyCommented1),
Position: &gitlab.NotePosition{
NewPath: alreadyCommented1.Result.Diagnostic.GetLocation().GetPath(),
NewLine: int(alreadyCommented1.Result.Diagnostic.GetLocation().GetRange().GetStart().GetLine()),
Expand All @@ -168,7 +168,7 @@ func TestGitLabMergeRequestDiscussionCommenter_Post_Flush_review_api(t *testing.
{
Notes: []*gitlab.Note{
{
Body: commentutil.CommentBody(alreadyCommented2),
Body: commentutil.MarkdownComment(alreadyCommented2),
Position: &gitlab.NotePosition{
NewPath: alreadyCommented2.Result.Diagnostic.GetLocation().GetPath(),
NewLine: int(alreadyCommented2.Result.Diagnostic.GetLocation().GetRange().GetStart().GetLine()),
Expand All @@ -191,7 +191,7 @@ func TestGitLabMergeRequestDiscussionCommenter_Post_Flush_review_api(t *testing.
switch got.Position.NewPath {
case "file.go":
want := &gitlab.CreateMergeRequestDiscussionOptions{
Body: gitlab.String(commentutil.CommentBody(newComment1)),
Body: gitlab.String(commentutil.MarkdownComment(newComment1)),
Position: &gitlab.NotePosition{
BaseSHA: "xxx", StartSHA: "xxx", HeadSHA: "sha", PositionType: "text", NewPath: "file.go", NewLine: 14},
}
Expand All @@ -200,7 +200,7 @@ func TestGitLabMergeRequestDiscussionCommenter_Post_Flush_review_api(t *testing.
}
case "file2.go":
want := &gitlab.CreateMergeRequestDiscussionOptions{
Body: gitlab.String(commentutil.CommentBody(newComment2)),
Body: gitlab.String(commentutil.MarkdownComment(newComment2)),
Position: &gitlab.NotePosition{
BaseSHA: "xxx", StartSHA: "xxx", HeadSHA: "sha", PositionType: "text", NewPath: "file2.go", NewLine: 15},
}
Expand All @@ -209,7 +209,7 @@ func TestGitLabMergeRequestDiscussionCommenter_Post_Flush_review_api(t *testing.
}
case "new_file.go":
want := &gitlab.CreateMergeRequestDiscussionOptions{
Body: gitlab.String(commentutil.CommentBody(newComment3)),
Body: gitlab.String(commentutil.MarkdownComment(newComment3)),
Position: &gitlab.NotePosition{
BaseSHA: "xxx", StartSHA: "xxx", HeadSHA: "sha", PositionType: "text",
NewPath: "new_file.go", NewLine: 14,
Expand Down

0 comments on commit 3a980f8

Please sign in to comment.