@pilatos/bitbucket-cli 1.10.0 → 1.10.1
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/index.js +46 -37
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -18285,6 +18285,45 @@ function extractErrorMessage(data) {
|
|
|
18285
18285
|
}
|
|
18286
18286
|
return;
|
|
18287
18287
|
}
|
|
18288
|
+
// src/services/reviewer.service.ts
|
|
18289
|
+
function extractReviewerUuids(reviewers) {
|
|
18290
|
+
if (!reviewers) {
|
|
18291
|
+
return [];
|
|
18292
|
+
}
|
|
18293
|
+
const list = Array.from(reviewers);
|
|
18294
|
+
const uuids = [];
|
|
18295
|
+
for (const reviewer of list) {
|
|
18296
|
+
if (reviewer.uuid) {
|
|
18297
|
+
uuids.push(reviewer.uuid);
|
|
18298
|
+
}
|
|
18299
|
+
}
|
|
18300
|
+
return uuids;
|
|
18301
|
+
}
|
|
18302
|
+
function buildReviewersUpdateBody(uuids) {
|
|
18303
|
+
const body = {
|
|
18304
|
+
type: "pullrequest",
|
|
18305
|
+
reviewers: uuids.map((uuid) => ({ type: "user", uuid }))
|
|
18306
|
+
};
|
|
18307
|
+
return body;
|
|
18308
|
+
}
|
|
18309
|
+
async function updatePullRequestReviewers(pullrequestsApi, repoContext, prId, transformUuids) {
|
|
18310
|
+
const prResponse = await pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdGet({
|
|
18311
|
+
workspace: repoContext.workspace,
|
|
18312
|
+
repoSlug: repoContext.repoSlug,
|
|
18313
|
+
pullRequestId: prId
|
|
18314
|
+
});
|
|
18315
|
+
const pr = prResponse.data;
|
|
18316
|
+
const currentUuids = extractReviewerUuids(pr.reviewers);
|
|
18317
|
+
const updatedUuids = transformUuids(currentUuids);
|
|
18318
|
+
const body = buildReviewersUpdateBody(updatedUuids);
|
|
18319
|
+
const response = await pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdPut({
|
|
18320
|
+
workspace: repoContext.workspace,
|
|
18321
|
+
repoSlug: repoContext.repoSlug,
|
|
18322
|
+
pullRequestId: prId,
|
|
18323
|
+
body
|
|
18324
|
+
});
|
|
18325
|
+
return response.data;
|
|
18326
|
+
}
|
|
18288
18327
|
// src/bootstrap.ts
|
|
18289
18328
|
import { createRequire } from "module";
|
|
18290
18329
|
|
|
@@ -23197,25 +23236,11 @@ class AddReviewerPRCommand extends BaseCommand {
|
|
|
23197
23236
|
selectedUser: options.username
|
|
23198
23237
|
});
|
|
23199
23238
|
const user = userResponse.data;
|
|
23200
|
-
const
|
|
23201
|
-
|
|
23202
|
-
|
|
23203
|
-
pullRequestId: prId
|
|
23204
|
-
});
|
|
23205
|
-
const pr = prResponse.data;
|
|
23206
|
-
const existingReviewers = pr.reviewers ? Array.from(pr.reviewers) : [];
|
|
23207
|
-
const reviewerUuids = existingReviewers.map((r) => r.uuid).filter(Boolean);
|
|
23208
|
-
if (!reviewerUuids.includes(user.uuid)) {
|
|
23209
|
-
reviewerUuids.push(user.uuid);
|
|
23210
|
-
}
|
|
23211
|
-
const response = await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdPut({
|
|
23212
|
-
workspace: repoContext.workspace,
|
|
23213
|
-
repoSlug: repoContext.repoSlug,
|
|
23214
|
-
pullRequestId: prId,
|
|
23215
|
-
body: {
|
|
23216
|
-
type: "pullrequest",
|
|
23217
|
-
reviewers: reviewerUuids.map((uuid) => ({ uuid }))
|
|
23239
|
+
const updatedPr = await updatePullRequestReviewers(this.pullrequestsApi, repoContext, prId, (uuids) => {
|
|
23240
|
+
if (!uuids.includes(user.uuid)) {
|
|
23241
|
+
return [...uuids, user.uuid];
|
|
23218
23242
|
}
|
|
23243
|
+
return uuids;
|
|
23219
23244
|
});
|
|
23220
23245
|
if (context.globalOptions.json) {
|
|
23221
23246
|
this.output.json({
|
|
@@ -23225,7 +23250,7 @@ class AddReviewerPRCommand extends BaseCommand {
|
|
|
23225
23250
|
username: options.username,
|
|
23226
23251
|
uuid: user.uuid
|
|
23227
23252
|
},
|
|
23228
|
-
pullRequest:
|
|
23253
|
+
pullRequest: updatedPr
|
|
23229
23254
|
});
|
|
23230
23255
|
return;
|
|
23231
23256
|
}
|
|
@@ -23256,23 +23281,7 @@ class RemoveReviewerPRCommand extends BaseCommand {
|
|
|
23256
23281
|
selectedUser: options.username
|
|
23257
23282
|
});
|
|
23258
23283
|
const user = userResponse.data;
|
|
23259
|
-
const
|
|
23260
|
-
workspace: repoContext.workspace,
|
|
23261
|
-
repoSlug: repoContext.repoSlug,
|
|
23262
|
-
pullRequestId: prId
|
|
23263
|
-
});
|
|
23264
|
-
const pr = prResponse.data;
|
|
23265
|
-
const existingReviewers = pr.reviewers ? Array.from(pr.reviewers) : [];
|
|
23266
|
-
const reviewerUuids = existingReviewers.map((r) => r.uuid).filter((uuid) => uuid && uuid !== user.uuid);
|
|
23267
|
-
const response = await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdPut({
|
|
23268
|
-
workspace: repoContext.workspace,
|
|
23269
|
-
repoSlug: repoContext.repoSlug,
|
|
23270
|
-
pullRequestId: prId,
|
|
23271
|
-
body: {
|
|
23272
|
-
type: "pullrequest",
|
|
23273
|
-
reviewers: reviewerUuids.map((uuid) => ({ uuid }))
|
|
23274
|
-
}
|
|
23275
|
-
});
|
|
23284
|
+
const updatedPr = await updatePullRequestReviewers(this.pullrequestsApi, repoContext, prId, (uuids) => uuids.filter((uuid) => uuid !== user.uuid));
|
|
23276
23285
|
if (context.globalOptions.json) {
|
|
23277
23286
|
this.output.json({
|
|
23278
23287
|
success: true,
|
|
@@ -23281,7 +23290,7 @@ class RemoveReviewerPRCommand extends BaseCommand {
|
|
|
23281
23290
|
username: options.username,
|
|
23282
23291
|
uuid: user.uuid
|
|
23283
23292
|
},
|
|
23284
|
-
pullRequest:
|
|
23293
|
+
pullRequest: updatedPr
|
|
23285
23294
|
});
|
|
23286
23295
|
return;
|
|
23287
23296
|
}
|