Skip to content

Commit 22bc457

Browse files
CyberShadowGeod24
authored andcommitted
Tag Enhancement and Bug in the same pull request
Fixes #95.
1 parent 3fc805f commit 22bc457

5 files changed

+88
-8
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"error" : null,
3+
"result" : {
4+
"bugs" : {
5+
"8573" : {
6+
"comments" : []
7+
},
8+
"8574" : {
9+
"comments" : []
10+
}
11+
},
12+
"comments" : {}
13+
}
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"error" : null,
3+
"result" : null
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"options": {
3+
"terms": [
4+
{
5+
"fields": [
6+
"name"
7+
],
8+
"text": "Issue 8574",
9+
"phrase": true,
10+
"partial": false
11+
}
12+
],
13+
"modifiers": [],
14+
"modelTypes": [
15+
"actions",
16+
"cards",
17+
"boards",
18+
"organizations",
19+
"members"
20+
],
21+
"partial": false
22+
},
23+
"boards": [],
24+
"cards": [],
25+
"organizations": [],
26+
"members": []
27+
}
28+

source/dlangbot/app.d

+5-8
Original file line numberDiff line numberDiff line change
@@ -255,18 +255,15 @@ void handlePR(string action, PullRequest* _pr)
255255
if (refs.any!(r => r.fixed))
256256
{
257257
import std.algorithm : canFind, filter, map, sort, uniq;
258-
import std.array : array;
258+
import std.array : assocArray;
259+
import std.typecons : tuple;
259260
// references are already sorted by id
260261
auto bugzillaIds = refs.map!(r => r.id).uniq;
261-
auto bugzillSeverities = descs
262+
auto labels = descs
262263
.filter!(d => bugzillaIds.canFind(d.id))
263-
.map!(i => i.severity);
264+
.map!(i => i.severity == "enhancement" ? "Enhancement" : "Bug Fix")
265+
.map!(label => tuple(label, true)).assocArray.keys; // unique
264266
logDebug("[github/handlePR](%s): trying to add bug fix label", _pr.pid);
265-
string[] labels;
266-
if (bugzillSeverities.canFind("enhancement"))
267-
labels ~= "Enhancement";
268-
else
269-
labels ~= "Bug Fix";
270267

271268
pr.addLabels(labels);
272269
}

test/comments.d

+37
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,43 @@ unittest
153153
postGitHubHook("dlang_phobos_synchronize_4921.json");
154154
}
155155

156+
@("multiple-severity-labels")
157+
unittest
158+
{
159+
setAPIExpectations(
160+
"/github/repos/dlang/phobos/pulls/4921/commits", (ref Json j) {
161+
j[0]["commit"]["message"] = "Fix Issue 8573, 8574";
162+
},
163+
"/github/repos/dlang/phobos/issues/4921/comments",
164+
"/bugzilla/buglist.cgi?bug_id=8573,8574&ctype=csv&columnlist=short_desc,bug_status,resolution,bug_severity,priority,keywords",
165+
(scope HTTPServerRequest req, scope HTTPServerResponse res){
166+
res.writeBody(
167+
`bug_id,"short_desc","bug_status","resolution","bug_severity","priority","keywords"
168+
8573,"A simpler Phobos function that returns the index of the mix or max item","NEW","---","enhancement","P2",
169+
8574,"Some Bug","NEW","---","normal","P2",`);
170+
},
171+
"/github/repos/dlang/phobos/issues/4921/labels",
172+
"/github/repos/dlang/phobos/issues/4921/labels", (ref Json j) {
173+
j = Json.emptyArray;
174+
},
175+
"/github/orgs/dlang/public_members?per_page=100",
176+
"/github/repos/dlang/phobos/issues/comments/262784442",
177+
(scope HTTPServerRequest req, scope HTTPServerResponse res){
178+
},
179+
"/github/repos/dlang/phobos/issues/4921/labels",
180+
(scope HTTPServerRequest req, scope HTTPServerResponse res){
181+
assert(req.json[].sort.equal(["Bug Fix", "Enhancement"]));
182+
},
183+
"/trello/1/search?query=name:%22Issue%208573%22&"~trelloAuth,
184+
"/trello/1/search?query=name:%22Issue%208574%22&"~trelloAuth,
185+
"/bugzilla/jsonrpc.cgi", // Bug.comments (#8573,#8574)
186+
"/bugzilla/jsonrpc.cgi", // Bug.update (#8573)
187+
"/bugzilla/jsonrpc.cgi", // Bug.update (#8574)
188+
);
189+
190+
postGitHubHook("dlang_phobos_synchronize_4921.json");
191+
}
192+
156193
@("do-not-readd-labels-1-#97")
157194
unittest
158195
{

0 commit comments

Comments
 (0)