spanOf

tcmts.cli.traced.spanOf · #rmff5m7j · term · runs anywhere

What a span is of, as named now.

import type { Codebase } from "#codebase/tcmts/cli/codebase";
import type { Of } from "#codebase/tcmts/cli/traced";

export function spanOf(cb: Codebase, s: { hash: string | null; name: string }): Of {
  if (!s.hash) return { hash: null, label: s.name, gone: false };
  const now = cb.store.pathsOf(s.hash)[0];
  if (now) return { hash: s.hash, label: now, gone: false };
  // (a version something newer replaced, which is named now: changed since, not renamed or removed)
  const replaced = cb.store.patched(s.hash);
  const named = replaced !== s.hash ? cb.store.pathsOf(replaced)[0] : undefined;
  return named
    ? { hash: s.hash, label: named, gone: true, earlier: true }
    : { hash: s.hash, label: s.name, gone: true };
}

uses

used by