releaseCommit

tcmts.cli.mirror.releaseCommit · #luusrens · term · runs on the server

uses node:path

The commit a release of a mirrored codebase is made from: the mirror's files must all be committed, so the release can be made again from git. Undefined when the mirror isn't in a git repository.

import { git, RECORDS } from "#codebase/tcmts/cli/mirror";
import type { Mirror } from "#codebase/tcmts/cli/mirror";
import path from "node:path";

export function releaseCommit(m: Mirror): string | undefined {
  if (git(m.dir, "rev-parse", "--is-inside-work-tree") !== "true") return undefined;
  const dirty = git(m.dir, "status", "--porcelain", "--", ".", `:!${RECORDS}`);
  if (dirty === undefined || dirty) {
    throw new Error(`${path.relative(process.cwd(), m.dir) || "the mirror"} has changes git doesn't have yet; commit them first, so the release can be made again from git`);
  }
  return git(m.dir, "rev-parse", "HEAD");
}

uses

used by