@bakers-build/addon-forge-github 0.11.1-next.7 → 0.11.1-next.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/index.js +34 -1
- package/package.json +4 -4
package/dist/src/index.js
CHANGED
|
@@ -105,7 +105,9 @@ const factory = async (raw, context) => {
|
|
|
105
105
|
};
|
|
106
106
|
return out.token;
|
|
107
107
|
};
|
|
108
|
-
const api = async (path, init = {}) =>
|
|
108
|
+
const api = async (path, init = {}) =>
|
|
109
|
+
// An absolute URL reaches the API outside the repository (user search).
|
|
110
|
+
(init.text ? requestText : requestJson)(doFetch, path.startsWith(API) ? path : `${repo}${path}`, {
|
|
109
111
|
method: init.method ?? 'GET',
|
|
110
112
|
headers: {
|
|
111
113
|
authorization: `Bearer ${await accessToken()}`,
|
|
@@ -253,6 +255,37 @@ const factory = async (raw, context) => {
|
|
|
253
255
|
issueLabels: unsupported,
|
|
254
256
|
updateIssueLabels: unsupported,
|
|
255
257
|
commentIssue: unsupported,
|
|
258
|
+
addReviewers: async (pr, mails) => {
|
|
259
|
+
const requested = [];
|
|
260
|
+
const skipped = [];
|
|
261
|
+
for (const mail of mails) {
|
|
262
|
+
// Search sees public e-mails only; an ambiguous hit is no match.
|
|
263
|
+
const found = (await api(`${API}/search/users?q=${encodeURIComponent(`${mail} in:email`)}`));
|
|
264
|
+
const login = found.total_count === 1 ? found.items[0]?.login : undefined;
|
|
265
|
+
if (!login) {
|
|
266
|
+
skipped.push({
|
|
267
|
+
mail,
|
|
268
|
+
reason: 'no GitHub user with this public e-mail',
|
|
269
|
+
});
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
try {
|
|
273
|
+
await api(`/pulls/${pr.number}/requested_reviewers`, {
|
|
274
|
+
method: 'POST',
|
|
275
|
+
body: { reviewers: [login] },
|
|
276
|
+
});
|
|
277
|
+
requested.push(mail);
|
|
278
|
+
}
|
|
279
|
+
catch (err) {
|
|
280
|
+
// 422: GitHub refuses this reviewer (the author, no access); others still go.
|
|
281
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
282
|
+
if (!/ answered 422: /.test(msg))
|
|
283
|
+
throw err;
|
|
284
|
+
skipped.push({ mail, reason: msg });
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
return { requested, skipped };
|
|
288
|
+
},
|
|
256
289
|
};
|
|
257
290
|
return backend;
|
|
258
291
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bakers-build/addon-forge-github",
|
|
3
|
-
"version": "0.11.1-next.
|
|
3
|
+
"version": "0.11.1-next.9",
|
|
4
4
|
"description": "bakers.build forge backend for GitHub: a GitHub App installation token scoped to one repository. Implements @bakers-build/addon-forge's ForgeBackend contract.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
"directory": "bakers-cli/addons/forge-github"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
|
-
"@bakers-build/addon-forge": "^0.11.1-next.
|
|
25
|
-
"@bakers-build/core": "^0.11.1-next.
|
|
24
|
+
"@bakers-build/addon-forge": "^0.11.1-next.9",
|
|
25
|
+
"@bakers-build/core": "^0.11.1-next.9"
|
|
26
26
|
},
|
|
27
27
|
"bakersBuild": {
|
|
28
|
-
"commit": "
|
|
28
|
+
"commit": "4c0c7ffab0be833fb9cbb50b0784a949593f08e6",
|
|
29
29
|
"channel": "next"
|
|
30
30
|
}
|
|
31
31
|
}
|