Skip to content

Commit

Permalink
Improve create events documentation and wording (#308)
Browse files Browse the repository at this point in the history
  • Loading branch information
hanzei authored Jun 18, 2020
1 parent 14a9ff7 commit eee8114
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ __If you are using GitHub Enterprise, replace all GitHub links below with your G
- **Payload URL**: `https://your-mattermost-url.com/plugins/github/webhook`, replacing `https://your-mattermost-url.com` with your Mattermost URL
- **Content Type**: `application/json`
- **Secret**: the webhook secret you copied previously
6. Select **Let me select individual events** for "Which events would you like to trigger this webhook?", then select the following events: Issues, Issue comments, Pull requests, Pull request reviews, Pull request review comments, Pushes, Branch or Tag creation, Branch or Tag deletion
6. Select **Let me select individual events** for "Which events would you like to trigger this webhook?", then select the following events: `Branch or Tag creation`, `Branch or Tag deletion`, `Issue comments`, `Issues`, `Pull requests`, `Pull request review`, `Pull request review comments`, `Pushes`
7. Hit **Add Webhook** to save it.

### Step 3: Configure plugin in Mattermost
Expand Down
4 changes: 2 additions & 2 deletions server/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,11 @@ func init() {
`))

template.Must(masterTemplate.New("newCreateMessage").Funcs(funcMap).Parse(`
{{template "user" .GetSender}} just created {{.GetRefType}} [\[{{.GetRepo.GetFullName}}:{{.GetRef}}\]]({{.GetRepo.GetHTMLURL}}/tree/{{.GetRef}})
{{template "repo" .GetRepo}} {{.GetRefType}} [{{.GetRef}}]({{.GetRepo.GetHTMLURL}}/tree/{{.GetRef}}) created by {{template "user" .GetSender}}
`))

template.Must(masterTemplate.New("newDeleteMessage").Funcs(funcMap).Parse(`
{{template "user" .GetSender}} just deleted {{.GetRefType}} \[{{.GetRepo.GetFullName}}:{{.GetRef}}]
{{template "repo" .GetRepo}} {{.GetRefType}} {{.GetRef}} deleted by {{template "user" .GetSender}}
`))

template.Must(masterTemplate.New("issueComment").Funcs(funcMap).Parse(`
Expand Down
8 changes: 4 additions & 4 deletions server/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,12 +460,12 @@ func TestPushedCommitsTemplate(t *testing.T) {

func TestCreateMessageTemplate(t *testing.T) {
expected := `
[panda](https://github.com/panda) just created branch [\[mattermost-plugin-github:branch\]](https://github.com/mattermost/mattermost-plugin-github/tree/branch)
[\[mattermost-plugin-github\]](https://github.com/mattermost/mattermost-plugin-github) branch [branchname](https://github.com/mattermost/mattermost-plugin-github/tree/branchname) created by [panda](https://github.com/panda)
`

actual, err := renderTemplate("newCreateMessage", &github.CreateEvent{
Repo: &repo,
Ref: sToP("branch"),
Ref: sToP("branchname"),
RefType: sToP("branch"),
Sender: &user,
})
Expand All @@ -475,12 +475,12 @@ func TestCreateMessageTemplate(t *testing.T) {

func TestDeletedMessageTemplate(t *testing.T) {
expected := `
[panda](https://github.com/panda) just deleted branch \[mattermost-plugin-github:branch]
[\[mattermost-plugin-github\]](https://github.com/mattermost/mattermost-plugin-github) branch branchname deleted by [panda](https://github.com/panda)
`

actual, err := renderTemplate("newDeleteMessage", &github.DeleteEvent{
Repo: &repo,
Ref: sToP("branch"),
Ref: sToP("branchname"),
RefType: sToP("branch"),
Sender: &user,
})
Expand Down
2 changes: 0 additions & 2 deletions server/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,13 +475,11 @@ func (p *Plugin) postCreateEvent(event *github.CreateEvent) {
repo := event.GetRepo()

subs := p.GetSubscribedChannelsForRepository(repo)

if len(subs) == 0 {
return
}

typ := event.GetRefType()

if typ != "tag" && typ != "branch" {
return
}
Expand Down

0 comments on commit eee8114

Please sign in to comment.