Skip to content

Commit 0d7f8ee

Browse files
Release 2.1.8 (#720)
* [GH-717] Implement subscription notification for pull request "reopened" event (#718) * [MI-3808] Fix issue: Subscription notification not working for pull request "reopened" event. * [MI-3808] Added test case for new template * [MI-3808] Review fix * bump version to 2.1.8 --------- Co-authored-by: Raghav Aggarwal <raghav.aggarwal@brightscout.com>
1 parent 34e32c4 commit 0d7f8ee

File tree

4 files changed

+38
-3
lines changed

4 files changed

+38
-3
lines changed

plugin.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
"description": "GitHub plugin for Mattermost.",
55
"homepage_url": "https://github.com/mattermost/mattermost-plugin-github",
66
"support_url": "https://github.com/mattermost/mattermost-plugin-github/issues",
7-
"release_notes_url": "https://github.com/mattermost/mattermost-plugin-github/releases/tag/v2.1.7",
7+
"release_notes_url": "https://github.com/mattermost/mattermost-plugin-github/releases/tag/v2.1.8",
88
"icon_path": "assets/icon.svg",
9-
"version": "2.1.7",
9+
"version": "2.1.8",
1010
"min_server_version": "6.5.0",
1111
"server": {
1212
"executables": {

server/plugin/template.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,10 @@ Assignees: {{range $i, $el := .Assignees -}} {{- if $i}}, {{end}}{{template "use
198198
{{- if .GetPullRequest.GetMerged }} merged
199199
{{- else }} closed
200200
{{- end }} by {{template "user" .GetSender}}.
201+
`))
202+
203+
template.Must(masterTemplate.New("reopenedPR").Funcs(funcMap).Parse(`
204+
{{template "repo" .GetRepo}} Pull request {{template "pullRequest" .GetPullRequest}} was reopened by {{template "user" .GetSender}}.
201205
`))
202206

203207
template.Must(masterTemplate.New("pullRequestLabelled").Funcs(funcMap).Parse(`

server/plugin/template_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,22 @@ func TestClosedPRMessageTemplate(t *testing.T) {
341341
})
342342
}
343343

344+
func TestReopenedPRMessageTemplate(t *testing.T) {
345+
t.Run("reopened", func(t *testing.T) {
346+
expected := `
347+
[\[mattermost-plugin-github\]](https://github.com/mattermost/mattermost-plugin-github) Pull request [#42 Leverage git-get-head](https://github.com/mattermost/mattermost-plugin-github/pull/42) was reopened by [panda](https://github.com/panda).
348+
`
349+
350+
actual, err := renderTemplate("reopenedPR", &github.PullRequestEvent{
351+
Repo: &repo,
352+
PullRequest: &pullRequest,
353+
Sender: &user,
354+
})
355+
require.NoError(t, err)
356+
require.Equal(t, expected, actual)
357+
})
358+
}
359+
344360
func TestPullRequestLabelledTemplate(t *testing.T) {
345361
expected := `
346362
#### Leverage git-get-head

server/plugin/webhook.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,12 @@ func (p *Plugin) postPullRequestEvent(event *github.PullRequestEvent) {
315315
}
316316

317317
action := event.GetAction()
318-
if action != actionOpened && action != actionLabeled && action != actionClosed {
318+
switch action {
319+
case actionOpened,
320+
actionReopened,
321+
actionLabeled,
322+
actionClosed:
323+
default:
319324
return
320325
}
321326

@@ -387,6 +392,16 @@ func (p *Plugin) postPullRequestEvent(event *github.PullRequestEvent) {
387392
post.Message = p.sanitizeDescription(newPRMessage)
388393
}
389394

395+
if action == actionReopened {
396+
reopenedPRMessage, err := renderTemplate("reopenedPR", event)
397+
if err != nil {
398+
p.client.Log.Warn("Failed to render template", "error", err.Error())
399+
return
400+
}
401+
402+
post.Message = p.sanitizeDescription(reopenedPRMessage)
403+
}
404+
390405
if action == actionClosed {
391406
post.Message = closedPRMessage
392407
}

0 commit comments

Comments
 (0)