-
Notifications
You must be signed in to change notification settings - Fork 83
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
[GH-262] Merge request approval subscription #307
[GH-262] Merge request approval subscription #307
Conversation
Hello @MatthewDorner, Thanks for your pull request! A Core Committer will review your pull request soon. For code contributions, you can learn more about the review process here. |
Removed incorrect commandHelp text.
Clean up comment formatting.
This PR has been automatically labelled "stale" because it hasn't had recent activity. |
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.
a few changes
server/webhook/merge_request.go
Outdated
case actionApproved: | ||
message = fmt.Sprintf("[%s](%s) approved your merge request [%s!%v](%s)", senderGitlabUsername, w.gitlabRetreiver.GetUserURL(senderGitlabUsername), event.ObjectAttributes.Target.PathWithNamespace, event.ObjectAttributes.IID, event.ObjectAttributes.URL) | ||
case actionUnapproved: | ||
message = fmt.Sprintf("[%s](%s) unapproved your merge request [%s!%v](%s)", senderGitlabUsername, w.gitlabRetreiver.GetUserURL(senderGitlabUsername), event.ObjectAttributes.Target.PathWithNamespace, event.ObjectAttributes.IID, event.ObjectAttributes.URL) |
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.
I would suggest a bit better wording like asked for changes
. Something like that
server/webhook/merge_request.go
Outdated
case actionApproved: | ||
message = fmt.Sprintf("[%s] Merge request [!%v %s](%s) was approved by [%s](%s)", repo.PathWithNamespace, pr.IID, pr.Title, pr.URL, senderGitlabUsername, w.gitlabRetreiver.GetUserURL(senderGitlabUsername)) | ||
case actionUnapproved: | ||
message = fmt.Sprintf("[%s] Merge request [!%v %s](%s) was unapproved by [%s](%s)", repo.PathWithNamespace, pr.IID, pr.Title, pr.URL, senderGitlabUsername, w.gitlabRetreiver.GetUserURL(senderGitlabUsername)) |
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.
ditto. something like needs changes
…com/matthewdorner/mattermost-plugin-gitlab into merge-request-approval-subscription
Not sure why the CircleCI checks are timing out. |
This PR has been automatically labelled "stale" because it hasn't had recent activity. |
Changed the messages, anything else to do? |
case actionApproved: | ||
message = fmt.Sprintf("[%s](%s) approved your merge request [%s!%v](%s)", senderGitlabUsername, w.gitlabRetreiver.GetUserURL(senderGitlabUsername), event.ObjectAttributes.Target.PathWithNamespace, event.ObjectAttributes.IID, event.ObjectAttributes.URL) | ||
case actionUnapproved: | ||
message = fmt.Sprintf("[%s](%s) requested changes to your merge request [%s!%v](%s)", senderGitlabUsername, w.gitlabRetreiver.GetUserURL(senderGitlabUsername), event.ObjectAttributes.Target.PathWithNamespace, event.ObjectAttributes.IID, event.ObjectAttributes.URL) |
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.
GitHub's convention is to use #
here, not sure about GitLab. I see other references to !
here though
message = fmt.Sprintf("[%s](%s) requested changes to your merge request [%s!%v](%s)", senderGitlabUsername, w.gitlabRetreiver.GetUserURL(senderGitlabUsername), event.ObjectAttributes.Target.PathWithNamespace, event.ObjectAttributes.IID, event.ObjectAttributes.URL) | |
message = fmt.Sprintf("[%s](%s) requested changes to your merge request [%s#%v](%s)", senderGitlabUsername, w.gitlabRetreiver.GetUserURL(senderGitlabUsername), event.ObjectAttributes.Target.PathWithNamespace, event.ObjectAttributes.IID, event.ObjectAttributes.URL) |
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.
GitLab does use !
(https://docs.gitlab.com/ee/user/markdown.html) but the MR references in the Channel messages are formatted differently from the DM ones. Looks like the DM ones are doing it the correct way.
I can quickly fix it here.
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.
In this screenshot, the second set of messages would be after my proposed changes where you can see the DM and Channel messages now format the MR reference in the same way. But I'd go even further and suggest that the sentence structure should also be the same instead of one being "X approved MR" and the other "MR was approved by". There's a bunch of little stuff like that I'm seeing but probably should be separate PRs.
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.
@mickmister should I also mention the reviewer in replies to review threads like this one? It's been a while since I used GitHub...
Anyway I don't think I should commit the screenshotted change as part of this PR. I'd rather review all the different types of webhook message templates and propose fixes in a later PR, but I do think there are multiple things that should be fixed.
But the use of !
itself is correct for GitLab MRs.
server/webhook/merge_request.go
Outdated
@@ -83,6 +87,10 @@ func (w *webhook) handleChannelMergeRequest(ctx context.Context, event *gitlab.M | |||
message = fmt.Sprintf("[%s] Merge request [!%v %s](%s) was closed by [%s](%s)", repo.PathWithNamespace, pr.IID, pr.Title, pr.URL, senderGitlabUsername, w.gitlabRetreiver.GetUserURL(senderGitlabUsername)) | |||
case actionReopen: | |||
message = fmt.Sprintf("[%s] Merge request [!%v %s](%s) was reopened by [%s](%s)", repo.PathWithNamespace, pr.IID, pr.Title, pr.URL, senderGitlabUsername, w.gitlabRetreiver.GetUserURL(senderGitlabUsername)) | |||
case actionApproved: | |||
message = fmt.Sprintf("[%s] Merge request [!%v %s](%s) was approved by [%s](%s)", repo.PathWithNamespace, pr.IID, pr.Title, pr.URL, senderGitlabUsername, w.gitlabRetreiver.GetUserURL(senderGitlabUsername)) |
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.
(Not part of this PR), but ideally we use the sender
's connected Mattermost account to display their Mattermost username instead of their GitLab username
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.
Couldn't the sender be somebody who hasn't connected their account?
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.
Yes, but we should do our best to use the connected account. If they aren't connected, then we should fall back to the default functionality
@MatthewDorner Make sure you either mention someone when asking a question or re-request review from the person if that's the context of the question |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #307 +/- ##
==========================================
+ Coverage 32.27% 32.43% +0.15%
==========================================
Files 21 21
Lines 3433 3441 +8
==========================================
+ Hits 1108 1116 +8
Misses 2215 2215
Partials 110 110
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
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.
thanks for the contribution
This PR has been automatically labelled "stale" because it hasn't had recent activity. |
Revert change to remove --verbose flag in Makefile
/update-branch |
@DHaussermann Gentle reminder to review this PR |
This PR has been automatically labelled "stale" because it hasn't had recent activity. |
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.
Tested and passed
- Created a subscription that includes
merge_request_comments
- Confirmed that both Approval and Revoke Approval now send webhook events for this feature.
- A DM is sent to the user
LGTM!
Thanks @MatthewDorner for implementing this! 🎉
Sorry for the delay in getting this approved.
@MatthewDorner Would you please merge |
…roval-subscription - Fixed merge conflicts
@hanzei done |
This PR has been automatically labelled "stale" because it hasn't had recent activity. |
Thank you for the contribution @MatthewDorner 👍 |
Summary
Add DM and Channel notifications for Merge Request
approved
andunapproved
webhook actions.Ticket Link
Fixes #282