closeContribution

tcmts.cli.contributions.closeContribution · #eh2yeg2d · term · runs anywhere

import type { Codebase } from "#codebase/tcmts/cli/codebase";
import { ContributionError, find } from "#codebase/tcmts/cli/contributions";

export function closeContribution(cb: Codebase, id: number, by: string, reopen = false) {
  const c = find(cb, id);
  if (reopen ? c.status !== "closed" : c.status !== "open")
    throw new ContributionError(`#${id} is ${c.status}`);
  cb.store.setContributionStatus(id, reopen ? "open" : "closed");
  cb.store.addComment(id, { author: by, body: reopen ? "reopened" : "closed" });
}

uses

used by