Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions server/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ func init() {
{{- else if eq .GetReview.GetState "changes_requested" }} requested changes on your pull request
{{- else if eq .GetReview.GetState "commented" }} commented on your pull request
{{- end }} {{template "reviewRepoPullRequestWithTitle" .}}
>{{.Review.GetBody | replaceAllGitHubUsernames}}
`))
{{if .GetReview.GetBody}}>{{.Review.GetBody | replaceAllGitHubUsernames}}
{{else}}{{end}}`))
Comment thread
marianunez marked this conversation as resolved.
Resolved
}

func registerGitHubToUsernameMappingCallback(callback func(string) string) {
Expand Down
17 changes: 17 additions & 0 deletions server/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,23 @@ func TestPullRequestReviewNotification(t *testing.T) {
require.NoError(t, err)
require.Equal(t, expected, actual)
}))
t.Run("review with no body", withGitHubUserNameMapping(func(t *testing.T) {
expected := `
@pandabot approved your pull request [mattermost-plugin-github#42](https://github.com/mattermost/mattermost-plugin-github/pull/42#issuecomment-123456) - Leverage git-get-head
`

actual, err := renderTemplate("pullRequestReviewNotification", &github.PullRequestReviewEvent{
Repo: &repo,
PullRequest: &pullRequest,
Sender: &user,
Review: &github.PullRequestReview{
HTMLURL: sToP("https://github.com/mattermost/mattermost-plugin-github/pull/42#issuecomment-123456"),
State: sToP("approved"),
},
})
require.NoError(t, err)
require.Equal(t, expected, actual)
}))
}

func TestGitHubUsernameRegex(t *testing.T) {
Expand Down