azdo-cli 0.5.0-019-fix-pr-command.344 → 0.5.0-019-fix-pr-command.346

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.
Files changed (2) hide show
  1. package/dist/index.js +26 -10
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -775,7 +775,10 @@ function noticeCredentialBearingRemote() {
775
775
  return;
776
776
  }
777
777
  warned = true;
778
- process.stderr.write(WARNING);
778
+ try {
779
+ process.stderr.write(WARNING);
780
+ } catch {
781
+ }
779
782
  }
780
783
 
781
784
  // src/services/git-remote.ts
@@ -2644,6 +2647,21 @@ function parsePositivePrNumber(raw) {
2644
2647
  const n = Number.parseInt(raw, 10);
2645
2648
  return Number.isFinite(n) && n > 0 ? n : null;
2646
2649
  }
2650
+ var PR_NUMBER_HELP = "target the pull request with this numeric id, instead of the current branch's PR. When omitted, the CLI auto-detects the pull request whose source branch equals refs/heads/<current branch> in the Azure DevOps repository identified by the origin remote; if zero or more than one open PR matches, the command fails with a message naming the searched branch.";
2651
+ function configureUnwrappedHelp(command) {
2652
+ return command.configureHelp({ helpWidth: 1e3 });
2653
+ }
2654
+ function autoDetectZeroMatch(branch) {
2655
+ return `No open pull request matches branch ${branch}. Pass --pr-number to target a specific PR, or push the branch and open a pull request.`;
2656
+ }
2657
+ function autoDetectMultiMatch(branch, ids) {
2658
+ return `Multiple open pull requests match branch ${branch}: ${ids.map((id) => `#${id}`).join(", ")}. Re-run with --pr-number to choose.`;
2659
+ }
2660
+ function writeContractError(line) {
2661
+ process.stderr.write(`${line}
2662
+ `);
2663
+ process.exitCode = 1;
2664
+ }
2647
2665
  function formatBranchName(refName) {
2648
2666
  return refName.startsWith("refs/heads/") ? refName.slice("refs/heads/".length) : refName;
2649
2667
  }
@@ -2819,7 +2837,7 @@ ${result.pullRequest.url ?? "\u2014"}
2819
2837
  }
2820
2838
  function createPrCommentsCommand() {
2821
2839
  const command = new Command12("comments");
2822
- command.description("List pull request comment threads for the current branch").option("--org <org>", "Azure DevOps organization").option("--project <project>", "Azure DevOps project").option("--pr-number <N>", "target the pull request with this numeric id, instead of the current branch's PR").option("--hide-resolved", "hide threads whose status is resolved / won't fix / closed / by design").option("--json", "output JSON").action(async (options) => {
2840
+ configureUnwrappedHelp(command).description("List pull request comment threads for the current branch").option("--org <org>", "Azure DevOps organization").option("--project <project>", "Azure DevOps project").option("--pr-number <N>", PR_NUMBER_HELP).option("--hide-resolved", "hide threads whose status is resolved / won't fix / closed / by design").option("--json", "output JSON").action(async (options) => {
2823
2841
  validateOrgProjectPair(options);
2824
2842
  let context;
2825
2843
  let explicitPrId = null;
@@ -2851,12 +2869,11 @@ function createPrCommentsCommand() {
2851
2869
  status: "active"
2852
2870
  });
2853
2871
  if (pullRequests.length === 0) {
2854
- writeError(`No active pull request found for branch ${resolved.branch}.`);
2872
+ writeContractError(autoDetectZeroMatch(resolved.branch));
2855
2873
  return;
2856
2874
  }
2857
2875
  if (pullRequests.length > 1) {
2858
- const ids = pullRequests.map((pr) => `#${pr.id}`).join(", ");
2859
- writeError(`Multiple active pull requests found for branch ${resolved.branch}: ${ids}. Use pr status to review them.`);
2876
+ writeContractError(autoDetectMultiMatch(resolved.branch, pullRequests.map((pr) => pr.id)));
2860
2877
  return;
2861
2878
  }
2862
2879
  pullRequest = pullRequests[0];
@@ -2920,12 +2937,11 @@ async function resolveThreadTarget(threadIdRaw, options) {
2920
2937
  status: "active"
2921
2938
  });
2922
2939
  if (pullRequests.length === 0) {
2923
- writeError(`No active pull request found for branch ${resolved.branch}.`);
2940
+ writeContractError(autoDetectZeroMatch(resolved.branch));
2924
2941
  return null;
2925
2942
  }
2926
2943
  if (pullRequests.length > 1) {
2927
- const ids = pullRequests.map((pr) => `#${pr.id}`).join(", ");
2928
- writeError(`Multiple active pull requests found for branch ${resolved.branch}: ${ids}. Use pr status to review them.`);
2944
+ writeContractError(autoDetectMultiMatch(resolved.branch, pullRequests.map((pr) => pr.id)));
2929
2945
  return null;
2930
2946
  }
2931
2947
  pullRequest = pullRequests[0];
@@ -2993,14 +3009,14 @@ async function runThreadStateChange(threadIdRaw, options, direction) {
2993
3009
  }
2994
3010
  function createPrCommentResolveCommand() {
2995
3011
  const command = new Command12("comment-resolve");
2996
- command.description("Mark a pull request comment thread as resolved").argument("<threadId>", "numeric id of the thread to resolve").option("--org <org>", "Azure DevOps organization").option("--project <project>", "Azure DevOps project").option("--pr-number <N>", "target the pull request with this numeric id, instead of the current branch's PR").option("--json", "output JSON").action(async (threadIdRaw, options) => {
3012
+ configureUnwrappedHelp(command).description("Mark a pull request comment thread as resolved").argument("<threadId>", "numeric id of the thread to resolve").option("--org <org>", "Azure DevOps organization").option("--project <project>", "Azure DevOps project").option("--pr-number <N>", PR_NUMBER_HELP).option("--json", "output JSON").action(async (threadIdRaw, options) => {
2997
3013
  await runThreadStateChange(threadIdRaw, options, "resolve");
2998
3014
  });
2999
3015
  return command;
3000
3016
  }
3001
3017
  function createPrCommentReopenCommand() {
3002
3018
  const command = new Command12("comment-reopen");
3003
- command.description("Reopen (set to active) a previously resolved pull request comment thread").argument("<threadId>", "numeric id of the thread to reopen").option("--org <org>", "Azure DevOps organization").option("--project <project>", "Azure DevOps project").option("--pr-number <N>", "target the pull request with this numeric id, instead of the current branch's PR").option("--json", "output JSON").action(async (threadIdRaw, options) => {
3019
+ configureUnwrappedHelp(command).description("Reopen (set to active) a previously resolved pull request comment thread").argument("<threadId>", "numeric id of the thread to reopen").option("--org <org>", "Azure DevOps organization").option("--project <project>", "Azure DevOps project").option("--pr-number <N>", PR_NUMBER_HELP).option("--json", "output JSON").action(async (threadIdRaw, options) => {
3004
3020
  await runThreadStateChange(threadIdRaw, options, "reopen");
3005
3021
  });
3006
3022
  return command;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "azdo-cli",
3
- "version": "0.5.0-019-fix-pr-command.344",
3
+ "version": "0.5.0-019-fix-pr-command.346",
4
4
  "description": "Azure DevOps CLI tool",
5
5
  "type": "module",
6
6
  "bin": {