@@ -40,10 +40,10 @@ string formatComment(R1, R2)(R1 refs, R2 descs)
4040
4141struct Comment { string url, body_; }
4242
43- Comment getBotComment (string commentsURL )
43+ Comment getBotComment (in ref PullRequest pr )
4444{
4545 // the bot may post multiple comments (mention-bot & bugzilla links)
46- auto res = ghGetRequest(commentsURL)
46+ auto res = ghGetRequest(pr. commentsURL)
4747 .readJson[]
4848 .find! (c => c[" user" ][" login" ] == " dlang-bot" && c[" body" ].get ! string .canFind(" Bugzilla" ));
4949 if (res.length)
@@ -87,9 +87,8 @@ auto ghSendRequest(T...)(HTTPMethod method, string url, T arg)
8787 }, url);
8888}
8989
90- void updateGithubComment (string action, IssueRef[] refs, Issue[] descs, string commentsURL )
90+ void updateGithubComment (in ref PullRequest pr, in ref Comment comment, string action, IssueRef[] refs, Issue[] descs)
9191{
92- auto comment = getBotComment(commentsURL);
9392 logDebug(" %s" , refs);
9493 if (refs.empty)
9594 {
@@ -108,7 +107,7 @@ void updateGithubComment(string action, IssueRef[] refs, Issue[] descs, string c
108107 if (comment.url.length)
109108 ghSendRequest(HTTPMethod.PATCH , comment.url, [" body" : msg]);
110109 else if (action != " closed" && action != " merged" )
111- ghSendRequest(HTTPMethod.POST , commentsURL, [" body" : msg]);
110+ ghSendRequest(HTTPMethod.POST , pr. commentsURL, [" body" : msg]);
112111 }
113112}
114113
@@ -232,12 +231,24 @@ Json[] tryMerge(in ref PullRequest pr, MergeMethod method)
232231
233232void checkAndRemoveMergeLabels (Json[] labels, in ref PullRequest pr)
234233{
235- foreach (label; labels.map! (l => l[" name" ].get ! string ).filter! (n => n.startsWith(" auto-merge" )))
236- {
237- auto labelUrl = " %s/repos/%s/issues/%d/labels/%s"
238- .format(githubAPIURL, pr.repoSlug, pr.number, label);
239- ghSendRequest(HTTPMethod.DELETE , labelUrl);
240- }
234+ labels
235+ .map! (l => l[" name" ].get ! string )
236+ .filter! (n => n.startsWith(" auto-merge" ))
237+ .each! (l => pr.removeLabel(l));
238+ }
239+
240+ void addLabels (in ref PullRequest pr, string [] labels)
241+ {
242+ auto labelUrl = " %s/repos/%s/issues/%d/labels"
243+ .format(githubAPIURL, pr.repoSlug, pr.number);
244+ ghSendRequest(HTTPMethod.POST , labelUrl, labels);
245+ }
246+
247+ void removeLabel (in ref PullRequest pr, string label)
248+ {
249+ auto labelUrl = " %s/repos/%s/issues/%d/labels/%s"
250+ .format(githubAPIURL, pr.repoSlug, pr.number, label);
251+ ghSendRequest(HTTPMethod.DELETE , labelUrl);
241252}
242253
243254string getUserEmail (string login)
0 commit comments