All files / src/commands/issue unresolve.ts

100% Statements 9/9
100% Branches 0/0
100% Functions 2/2
100% Lines 9/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62                              11x   11x               1x     11x                                 1x   1x           1x       1x 1x      
/**
 * sentry issue unresolve (aliased: reopen)
 *
 * Move an issue back to the "unresolved" state. Inverse of `issue resolve`.
 */
 
import type { SentryContext } from "../../context.js";
import { updateIssueStatus } from "../../lib/api-client.js";
import { buildCommand } from "../../lib/command.js";
import { formatIssueDetails, muted } from "../../lib/formatters/index.js";
import { CommandOutput } from "../../lib/formatters/output.js";
import { logger } from "../../lib/logger.js";
import type { SentryIssue } from "../../types/index.js";
import { issueIdPositional, resolveIssue } from "./utils.js";
 
const log = logger.withTag("issue.unresolve");
 
const COMMAND = "unresolve";
 
type UnresolveFlags = {
  readonly json: boolean;
  readonly fields?: string[];
};
 
function formatUnresolved(issue: SentryIssue): string {
  return `${muted("Reopened")}\n\n${formatIssueDetails(issue)}`;
}
 
export const unresolveCommand = buildCommand({
  docs: {
    brief: "Reopen a resolved issue",
    fullDescription:
      "Mark an issue as unresolved. Inverse of `sentry issue resolve`.\n\n" +
      "Examples:\n" +
      "  sentry issue unresolve CLI-12Z\n" +
      "  sentry issue reopen CLI-12Z\n" +
      "  sentry issue unresolve my-org/CLI-AB",
  },
  output: {
    human: formatUnresolved,
  },
  parameters: {
    positional: issueIdPositional,
  },
  async *func(this: SentryContext, _flags: UnresolveFlags, issueArg: string) {
    const { cwd } = this;
 
    const { org, issue } = await resolveIssue({
      issueArg,
      cwd,
      command: COMMAND,
    });
 
    const updated = await updateIssueStatus(issue.id, "unresolved", {
      orgSlug: org,
    });
 
    log.debug(`Reopened ${updated.shortId}`);
    yield new CommandOutput<SentryIssue>(updated);
  },
});