azdo-cli 0.5.0-017-pr-comments-threads.240 → 0.5.0-017-pr-comments-threads.242

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 +11 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2396,6 +2396,10 @@ function mapThread(thread) {
2396
2396
  comments
2397
2397
  };
2398
2398
  }
2399
+ var RESOLVED_THREAD_STATUSES = /* @__PURE__ */ new Set(["fixed", "wontFix", "closed", "byDesign"]);
2400
+ function isThreadResolved(status) {
2401
+ return RESOLVED_THREAD_STATUSES.has(status);
2402
+ }
2399
2403
  async function readJsonResponse(response) {
2400
2404
  if (!response.ok) {
2401
2405
  throw new Error(`HTTP_${response.status}`);
@@ -2525,10 +2529,13 @@ function formatPullRequestBlock(pullRequest) {
2525
2529
  ...formatPullRequestChecks(pullRequest.checks)
2526
2530
  ].join("\n");
2527
2531
  }
2532
+ function threadStatusLabel(status) {
2533
+ return isThreadResolved(status) ? "resolved" : status;
2534
+ }
2528
2535
  function formatThreads(prId, title, threads) {
2529
2536
  const lines = [`Active comments for pull request #${prId}: ${title}`];
2530
2537
  for (const thread of threads) {
2531
- lines.push("", `Thread #${thread.id} [${thread.status}] ${thread.threadContext ?? "(general)"}`);
2538
+ lines.push("", `Thread #${thread.id} [${threadStatusLabel(thread.status)}] ${thread.threadContext ?? "(general)"}`);
2532
2539
  for (const comment of thread.comments) {
2533
2540
  lines.push(` ${comment.author ?? "Unknown"}: ${comment.content}`);
2534
2541
  }
@@ -2641,7 +2648,7 @@ ${result.pullRequest.url ?? "\u2014"}
2641
2648
  }
2642
2649
  function createPrCommentsCommand() {
2643
2650
  const command = new Command12("comments");
2644
- command.description("List active pull request comments for the current branch").option("--org <org>", "Azure DevOps organization").option("--project <project>", "Azure DevOps project").option("--json", "output JSON").action(async (options) => {
2651
+ command.description("List pull request comment threads for the current branch").option("--org <org>", "Azure DevOps organization").option("--project <project>", "Azure DevOps project").option("--hide-resolved", "hide threads whose status is resolved / won't fix / closed / by design").option("--json", "output JSON").action(async (options) => {
2645
2652
  validateOrgProjectPair(options);
2646
2653
  let context;
2647
2654
  try {
@@ -2660,7 +2667,8 @@ function createPrCommentsCommand() {
2660
2667
  return;
2661
2668
  }
2662
2669
  const pullRequest = pullRequests[0];
2663
- const threads = await getPullRequestThreads(resolved.context, resolved.repo, resolved.pat, pullRequest.id);
2670
+ const allThreads = await getPullRequestThreads(resolved.context, resolved.repo, resolved.pat, pullRequest.id);
2671
+ const threads = options.hideResolved ? allThreads.filter((thread) => !isThreadResolved(thread.status)) : allThreads;
2664
2672
  const result = { branch: resolved.branch, pullRequest, threads };
2665
2673
  if (options.json) {
2666
2674
  process.stdout.write(`${JSON.stringify(result, null, 2)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "azdo-cli",
3
- "version": "0.5.0-017-pr-comments-threads.240",
3
+ "version": "0.5.0-017-pr-comments-threads.242",
4
4
  "description": "Azure DevOps CLI tool",
5
5
  "type": "module",
6
6
  "bin": {