-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MM-405]: Fixed the pull review request events not working #768
Changes from 5 commits
2ac75ae
81c88e3
f0dd395
5fae2f3
e01f4e1
f086e6d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -308,9 +308,9 @@ Assignees: {{range $i, $el := .Assignees -}} {{- if $i}}, {{end}}{{template "use | |
|
||
template.Must(masterTemplate.New("pullRequestReviewEvent").Funcs(funcMap).Parse(` | ||
{{template "repo" .GetRepo}} {{template "user" .GetSender}} | ||
{{- if eq .GetReview.GetState "APPROVED"}} approved | ||
{{- else if eq .GetReview.GetState "COMMENTED"}} commented on | ||
{{- else if eq .GetReview.GetState "CHANGES_REQUESTED"}} requested changes on | ||
{{- if eq .GetReview.GetState "approved"}} approved | ||
{{- else if eq .GetReview.GetState "commented"}} commented on | ||
{{- else if eq .GetReview.GetState "changes_requested"}} requested changes on | ||
{{- end }} {{template "pullRequest" .GetPullRequest}}: | ||
|
||
{{.Review.GetBody | replaceAllGitHubUsernames}} | ||
|
@@ -319,7 +319,6 @@ Assignees: {{range $i, $el := .Assignees -}} {{- if $i}}, {{end}}{{template "use | |
template.Must(masterTemplate.New("newReviewComment").Funcs(funcMap).Parse(` | ||
{{template "repo" .GetRepo}} New review comment by {{template "user" .GetSender}} on {{template "pullRequest" .GetPullRequest}}: | ||
|
||
{{.GetComment.GetDiffHunk}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you provide a screenshot for what this looks like? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
{{.GetComment.GetBody | trimBody | replaceAllGitHubUsernames}} | ||
`)) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -843,10 +843,10 @@ func (p *Plugin) postPullRequestReviewEvent(event *github.PullRequestReviewEvent | |
return | ||
} | ||
|
||
switch strings.ToUpper(event.GetReview().GetState()) { | ||
case "APPROVED": | ||
case "COMMENTED": | ||
case "CHANGES_REQUESTED": | ||
switch event.GetReview().GetState() { | ||
case "approved": | ||
case "commented": | ||
case "changes_requested": | ||
default: | ||
p.client.Log.Debug("Unhandled review state", "state", event.GetReview().GetState()) | ||
return | ||
|
@@ -935,7 +935,7 @@ func (p *Plugin) postPullRequestReviewCommentEvent(event *github.PullRequestRevi | |
continue | ||
} | ||
|
||
post := p.makeBotPost(newReviewMessage, "custom_git_pull_review_comment") | ||
post := p.makeBotPost(newReviewMessage, "custom_git_pr_comment") | ||
|
||
repoName := strings.ToLower(repo.GetFullName()) | ||
commentID := event.GetComment().GetID() | ||
|
@@ -945,8 +945,8 @@ func (p *Plugin) postPullRequestReviewCommentEvent(event *github.PullRequestRevi | |
post.AddProp(postPropGithubObjectType, githubObjectTypePRReviewComment) | ||
|
||
post.ChannelId = sub.ChannelID | ||
if err = p.client.Post.CreatePost(post); err != nil { | ||
p.client.Log.Warn("Error webhook post", "post", post, "error", err.Error()) | ||
if _, appErr := p.API.CreatePost(post); appErr != nil { | ||
p.client.Log.Warn("Error webhook post", "post", post, "error", appErr.Error()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @hanzei Please refer to this comment: #768 (comment) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this case, the 2/5 The benefits of using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Kshitij-Katiyar I'm thinking we should keep the changes in this PR to a minimum so let's keep this as-is |
||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did GitHub document the changes anywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hanzei I was getting the state in small case and in the code as well they have been changed to lower case in the using toLower. Let me try to find the GitHub documentation for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hanzei Can't find a documentation but here is a screenshot of the webhook payload