azdo-cli 0.22.0-develop.769 → 0.22.0-develop.782
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 +48 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -80,6 +80,8 @@ azdo pr comments --exclude-system --max-chars 500 # human comments only, trun
|
|
|
80
80
|
azdo pr comments --thread 148 # a single thread, by id (selector: exit 1 if absent)
|
|
81
81
|
azdo pr comments --contains '"kind":"review-plan"' # threads holding a literal substring
|
|
82
82
|
azdo pr status # PR checks (status + branch policies + pipeline builds) + code-comment counts
|
|
83
|
+
azdo pr status --branch feature/x --json # same view for another branch, nothing checked out
|
|
84
|
+
azdo pr status --pr-number 64 # same view for one PR by number, any status
|
|
83
85
|
azdo pr comment-resolve 17 --pr-number 64 # idempotent: exit 0 even when already resolved
|
|
84
86
|
azdo pr comment-reopen 17 --pr-number 64
|
|
85
87
|
|
package/dist/index.js
CHANGED
|
@@ -4368,7 +4368,7 @@ function parsePositivePrNumber(raw) {
|
|
|
4368
4368
|
return null;
|
|
4369
4369
|
}
|
|
4370
4370
|
const n = Number.parseInt(raw, 10);
|
|
4371
|
-
return Number.
|
|
4371
|
+
return Number.isSafeInteger(n) && n > 0 ? n : null;
|
|
4372
4372
|
}
|
|
4373
4373
|
function prNumberHelp(branchStatus = "active") {
|
|
4374
4374
|
const matched = branchStatus === "abandoned" ? "abandoned" : "open";
|
|
@@ -4678,16 +4678,59 @@ async function resolvePrCommandContext(options, resolveOpts = {}) {
|
|
|
4678
4678
|
pat: credential
|
|
4679
4679
|
};
|
|
4680
4680
|
}
|
|
4681
|
+
var STATUS_PR_NUMBER_HELP = "show only the pull request with this numeric id, instead of the current branch's pull requests; mutually exclusive with --branch";
|
|
4682
|
+
var STATUS_BRANCH_HELP = "show the pull requests whose source branch is this one (with or without the refs/heads/ prefix), instead of the current branch's; no checkout needed. Mutually exclusive with --pr-number";
|
|
4683
|
+
function parseStatusTarget(options) {
|
|
4684
|
+
if (options.prNumber !== void 0 && options.branch !== void 0) {
|
|
4685
|
+
writeError("Cannot specify both --pr-number and --branch.");
|
|
4686
|
+
return null;
|
|
4687
|
+
}
|
|
4688
|
+
if (options.branch !== void 0) {
|
|
4689
|
+
const branch = options.branch.trim().replace(/^refs\/heads\//, "");
|
|
4690
|
+
if (branch === "") {
|
|
4691
|
+
writeError("--branch must not be empty.");
|
|
4692
|
+
return null;
|
|
4693
|
+
}
|
|
4694
|
+
return { kind: "branch", branch };
|
|
4695
|
+
}
|
|
4696
|
+
const prId = parseTargetPrNumber(options);
|
|
4697
|
+
if (prId === "invalid") {
|
|
4698
|
+
return null;
|
|
4699
|
+
}
|
|
4700
|
+
return prId === "none" ? { kind: "current" } : { kind: "pr", prId };
|
|
4701
|
+
}
|
|
4702
|
+
async function findStatusPullRequests(resolved, target) {
|
|
4703
|
+
if (target.kind === "pr") {
|
|
4704
|
+
const pullRequest = await fetchTargetById(resolved, target.prId);
|
|
4705
|
+
return pullRequest === null ? null : { branch: formatBranchName(pullRequest.sourceRefName), pullRequests: [pullRequest] };
|
|
4706
|
+
}
|
|
4707
|
+
const branch = target.kind === "branch" ? target.branch : resolved.branch;
|
|
4708
|
+
const pullRequests = await listPullRequests(resolved.context, resolved.repo, resolved.pat, branch);
|
|
4709
|
+
if (target.kind === "branch" && pullRequests.length === 0) {
|
|
4710
|
+
writeError(
|
|
4711
|
+
`No pull requests found for branch ${branch} in ${resolved.context.org}/${resolved.context.project}/${resolved.repo}.`
|
|
4712
|
+
);
|
|
4713
|
+
return null;
|
|
4714
|
+
}
|
|
4715
|
+
return { branch, pullRequests };
|
|
4716
|
+
}
|
|
4681
4717
|
function createPrStatusCommand() {
|
|
4682
4718
|
const command = new Command12("status");
|
|
4683
|
-
withCommonPrOptions(command).description("Check pull requests for the current branch").option("--json", "output JSON").action(async (options) => {
|
|
4719
|
+
withCommonPrOptions(configureUnwrappedHelp(command)).description("Check pull requests for the current branch, another branch, or a specific pull request").option("--pr-number <id>", STATUS_PR_NUMBER_HELP).option("--branch <name>", STATUS_BRANCH_HELP).option("--json", "output JSON").action(async (options) => {
|
|
4684
4720
|
validateOrgProjectPair(options);
|
|
4721
|
+
const target = parseStatusTarget(options);
|
|
4722
|
+
if (target === null) {
|
|
4723
|
+
return;
|
|
4724
|
+
}
|
|
4685
4725
|
let context;
|
|
4686
4726
|
try {
|
|
4687
|
-
const resolved = await resolvePrCommandContext(options);
|
|
4727
|
+
const resolved = await resolvePrCommandContext(options, { requireBranch: target.kind === "current" });
|
|
4688
4728
|
context = resolved.context;
|
|
4689
|
-
const
|
|
4690
|
-
|
|
4729
|
+
const found = await findStatusPullRequests(resolved, target);
|
|
4730
|
+
if (found === null) {
|
|
4731
|
+
return;
|
|
4732
|
+
}
|
|
4733
|
+
const { branch, pullRequests } = found;
|
|
4691
4734
|
let projectId = null;
|
|
4692
4735
|
try {
|
|
4693
4736
|
projectId = await resolveProjectId(resolved.context, resolved.pat);
|