azdo-cli 0.22.0-develop.790 → 0.22.0-develop.793
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/README.md +2 -0
- package/dist/index.js +63 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -123,6 +123,8 @@ azdo pr work-items unlink 1234 --pr-number 64
|
|
|
123
123
|
azdo pr reviewers add jane@example.com --pr-number 64 # optional by default
|
|
124
124
|
azdo pr reviewers add jane@example.com --pr-number 64 --required # required (or promotes in place)
|
|
125
125
|
azdo pr reviewers remove jane@example.com --pr-number 64
|
|
126
|
+
azdo pr reviewers list --pr-number 64 # who must review, and how each voted
|
|
127
|
+
azdo pr reviewers list --pr-number 64 --json # { pullRequestId, reviewers: [{ id, uniqueName, isRequired, vote, voteState, ... }] }
|
|
126
128
|
|
|
127
129
|
# Any pr subcommand can target another repository
|
|
128
130
|
azdo pr comments --repo other-repo --pr-number 12
|
package/dist/index.js
CHANGED
|
@@ -4261,13 +4261,34 @@ function buildPullRequestReviewerUrl(context, repo, prId, reviewerId) {
|
|
|
4261
4261
|
url.searchParams.set("api-version", "7.1");
|
|
4262
4262
|
return url;
|
|
4263
4263
|
}
|
|
4264
|
+
function reviewerVoteState(vote) {
|
|
4265
|
+
switch (vote) {
|
|
4266
|
+
case 10:
|
|
4267
|
+
return "approved";
|
|
4268
|
+
case 5:
|
|
4269
|
+
return "approved-with-suggestions";
|
|
4270
|
+
case 0:
|
|
4271
|
+
return "no-vote";
|
|
4272
|
+
case -5:
|
|
4273
|
+
return "waiting-for-author";
|
|
4274
|
+
case -10:
|
|
4275
|
+
return "rejected";
|
|
4276
|
+
case 15:
|
|
4277
|
+
return "bypassed";
|
|
4278
|
+
default:
|
|
4279
|
+
return "unknown";
|
|
4280
|
+
}
|
|
4281
|
+
}
|
|
4264
4282
|
function mapReviewer(data) {
|
|
4283
|
+
const vote = data.vote ?? 0;
|
|
4265
4284
|
return {
|
|
4266
4285
|
id: data.id,
|
|
4267
4286
|
displayName: data.displayName ?? null,
|
|
4268
4287
|
uniqueName: data.uniqueName ?? null,
|
|
4269
4288
|
isRequired: data.isRequired ?? false,
|
|
4270
|
-
vote
|
|
4289
|
+
vote,
|
|
4290
|
+
voteState: reviewerVoteState(vote),
|
|
4291
|
+
hasDeclined: data.hasDeclined ?? false
|
|
4271
4292
|
};
|
|
4272
4293
|
}
|
|
4273
4294
|
async function getPullRequestReviewers(context, repo, cred, prId) {
|
|
@@ -6087,9 +6108,50 @@ async function runReviewerRemove(reviewer, options) {
|
|
|
6087
6108
|
handlePrCommandError(err, context, "write");
|
|
6088
6109
|
}
|
|
6089
6110
|
}
|
|
6111
|
+
function formatReviewerLine(reviewer) {
|
|
6112
|
+
const name = reviewer.displayName ?? reviewer.uniqueName ?? reviewer.id;
|
|
6113
|
+
const unique = reviewer.uniqueName && reviewer.uniqueName !== name ? ` <${reviewer.uniqueName}>` : "";
|
|
6114
|
+
const kind = reviewer.isRequired ? "required" : "optional";
|
|
6115
|
+
const declined = reviewer.hasDeclined ? ", declined" : "";
|
|
6116
|
+
return `${name}${unique} \u2014 ${reviewer.voteState} (${kind}${declined})`;
|
|
6117
|
+
}
|
|
6118
|
+
async function runReviewerList(options) {
|
|
6119
|
+
let context;
|
|
6120
|
+
try {
|
|
6121
|
+
const target = await resolvePullRequestTarget(options, {
|
|
6122
|
+
onContextResolved: (resolved) => {
|
|
6123
|
+
context = resolved;
|
|
6124
|
+
}
|
|
6125
|
+
});
|
|
6126
|
+
if (target === null) {
|
|
6127
|
+
return;
|
|
6128
|
+
}
|
|
6129
|
+
const reviewers = await getPullRequestReviewers(target.context, target.repo, target.pat, target.pullRequest.id);
|
|
6130
|
+
const result = { pullRequestId: target.pullRequest.id, reviewers };
|
|
6131
|
+
if (options.json) {
|
|
6132
|
+
process.stdout.write(`${JSON.stringify(result, null, 2)}
|
|
6133
|
+
`);
|
|
6134
|
+
return;
|
|
6135
|
+
}
|
|
6136
|
+
if (reviewers.length === 0) {
|
|
6137
|
+
process.stdout.write(`No reviewers on pull request #${target.pullRequest.id}.
|
|
6138
|
+
`);
|
|
6139
|
+
return;
|
|
6140
|
+
}
|
|
6141
|
+
process.stdout.write(`${reviewers.map(formatReviewerLine).join("\n")}
|
|
6142
|
+
`);
|
|
6143
|
+
} catch (err) {
|
|
6144
|
+
handlePrCommandError(err, context, "read");
|
|
6145
|
+
}
|
|
6146
|
+
}
|
|
6090
6147
|
function createPrReviewersCommand() {
|
|
6091
6148
|
const command = new Command12("reviewers");
|
|
6092
6149
|
command.description("Manage pull request reviewers");
|
|
6150
|
+
const list = new Command12("list");
|
|
6151
|
+
withCommonPrOptions(configureUnwrappedHelp(list)).description("List the pull request reviewers with their votes (approved, waiting-for-author, \u2026) and required flag").option("--pr-number <N>", PR_NUMBER_HELP).option("--json", "output JSON").action(async (_options, command2) => {
|
|
6152
|
+
await runReviewerList(mergedPrOptions(command2));
|
|
6153
|
+
});
|
|
6154
|
+
command.addCommand(list);
|
|
6093
6155
|
const add = new Command12("add");
|
|
6094
6156
|
withCommonPrOptions(configureUnwrappedHelp(add)).description("Add a reviewer to the pull request (optional by default)").argument("<reviewer>", "reviewer email or unique name").option("--required", "mark the reviewer as required instead of optional").option("--pr-number <N>", PR_NUMBER_HELP).option("--json", "output JSON").action(async (reviewer, _options, command2) => {
|
|
6095
6157
|
await runReviewerAdd(reviewer, mergedPrOptions(command2));
|