Skip to content

Commit 624c8db

Browse files
stop mentioning users when they create a PR (#261)
* stop mentioning users when they create a PR - creates notifications that seem fairly pointless given that people just created the PR - not sure people with mail workflows have a different perspective on this * dlangbot.github: Preserve formatting of fake mentions Use the trick from github/markup#1168 (comment). * dlang-bot.test.comments: Update test suite Co-authored-by: Vladimir Panteleev <[email protected]>
1 parent d8dcce8 commit 624c8db

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

source/dlangbot/github.d

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,19 @@ string formatComment(in ref PullRequest pr, in IssueRef[] refs, in Issue[] descs
6363
.deserializeJson!(GHUser[])
6464
.canFind!(l => l.login == pr.user.login);
6565

66+
// Avoid actually mentioning users when referring to them
67+
auto userRef = `**@<!-- -->%s**`.format(pr.user.login);
68+
6669
if (isMember)
6770
{
6871
app.formattedWrite(
69-
`Thanks for your pull request, @%s!
70-
`, pr.user.login, pr.repoSlug);
72+
`Thanks for your pull request, %s!
73+
`, userRef, pr.repoSlug);
7174
}
7275
else
7376
{
7477
app.formattedWrite(
75-
"Thanks for your pull request and interest in making D better, @%s! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
78+
"Thanks for your pull request and interest in making D better, %s! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
7679
Please verify that your PR follows this checklist:
7780
7881
- My PR is fully covered with tests (you can see the coverage diff by visiting the _details_ link of the codecov check)
@@ -85,7 +88,7 @@ Please see [CONTRIBUTING.md](https://github.com/%s/blob/master/CONTRIBUTING.md)
8588
---
8689
8790
If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.",
88-
pr.user.login, pr.repoSlug);
91+
userRef, pr.repoSlug);
8992
}
9093

9194
// markdown doesn't support breaking of long lines

test/comments.d

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ unittest
8181
(scope HTTPServerRequest req, scope HTTPServerResponse res){
8282
assert(req.method == HTTPMethod.PATCH);
8383
auto body_= req.json["body"].get!string;
84-
assert(body_.canFind("@andralex"));
84+
assert(body_.canFind("**@<!-- -->andralex**"));
8585
assert(!body_.canFind("Auto-close | Bugzilla"), "Shouldn't contain bug header");
8686
assert(!body_.canFind("/show_bug.cgi?id="), "Shouldn't contain a Bugzilla reference");
8787
}
@@ -107,7 +107,7 @@ unittest
107107
(scope HTTPServerRequest req, scope HTTPServerResponse res){
108108
assert(req.method == HTTPMethod.PATCH);
109109
auto body_= req.json["body"].get!string;
110-
assert(body_.canFind("@andralex"));
110+
assert(body_.canFind("**@<!-- -->andralex**"));
111111
assert(!body_.canFind("Auto-close | Bugzilla"), "Shouldn't contain bug header");
112112
assert(!body_.canFind("/show_bug.cgi?id="), "Shouldn't contain a Bugzilla reference");
113113
}
@@ -139,7 +139,7 @@ unittest
139139
(scope HTTPServerRequest req, scope HTTPServerResponse res){
140140
assert(req.method == HTTPMethod.PATCH);
141141
auto body_= req.json["body"].get!string;
142-
assert(body_.canFind("@andralex"));
142+
assert(body_.canFind("**@<!-- -->andralex**"));
143143
},
144144
"/github/repos/dlang/phobos/issues/4921/labels",
145145
(scope HTTPServerRequest req, scope HTTPServerResponse res){
@@ -208,7 +208,7 @@ unittest
208208
(scope HTTPServerRequest req, scope HTTPServerResponse res){
209209
assert(req.method == HTTPMethod.PATCH);
210210
auto body_= req.json["body"].get!string;
211-
assert(body_.canFind("@andralex"));
211+
assert(body_.canFind("**@<!-- -->andralex**"));
212212
},
213213
"/trello/1/search?query=name:%22Issue%208573%22&"~trelloAuth,
214214
"/bugzilla/jsonrpc.cgi", // Bug.comments
@@ -317,7 +317,7 @@ unittest
317317
"/github/repos/dlang/phobos/issues/comments/262784442",
318318
(scope HTTPServerRequest req, scope HTTPServerResponse res){
319319
assert(req.method == HTTPMethod.PATCH);
320-
assert(req.json["body"].get!string.canFind("Thanks for your pull request, @andralex!"));
320+
assert(req.json["body"].get!string.canFind("Thanks for your pull request, **@<!-- -->andralex**!"));
321321
// don't show the the default contributors advice
322322
assert(!req.json["body"].get!string.canFind("CONTRIBUTING"));
323323
},
@@ -479,7 +479,7 @@ unittest
479479
(scope HTTPServerRequest req, scope HTTPServerResponse res){
480480
assert(req.method == HTTPMethod.PATCH);
481481
auto body_ = req.json["body"].get!string;
482-
assert(body_.canFind("@andralex"));
482+
assert(body_.canFind("**@<!-- -->andralex**"));
483483
assert(!body_.canFind("Auto-close | Bugzilla"), "Shouldn't contain bug header");
484484
assert(!body_.canFind("/show_bug.cgi?id="), "Shouldn't contain a Bugzilla reference");
485485
}

0 commit comments

Comments
 (0)