/** * Decision core of the pre-push capture hook. * * The generated `.husky`/`.githooks` pre-push file is a thin shim that execs the * packaged `styleproof-prepush` command; every behavioral rule lives HERE so hook * behavior updates with the styleproof release instead of with a bash file copied * into each consumer repo (and then hand-maintained, drifting, per consumer). * * The rules mirror the original shell hook exactly: * - git feeds pre-push one line per ref on stdin: * ` `. Capture the ref whose * tip is the CHECKED-OUT tree — the only commit whose render we can faithfully * capture and bind to its SHA. Pushing some other branch (local-oid != HEAD) * is left for CI to recapture, never captured from the wrong tree under that * SHA. * - A docs-only push (every changed file is a non-render doc) skips capture — * always safe, CI just recaptures on a cache miss. A new ref (zero remote-oid) * or an unreadable range never skips. * - No refs on stdin (a manual run, or an older git): fall back to HEAD. * * Pure and side-effect-free (git access is injected) so it is fully unit-testable. */ /** One stdin line of the pre-push hook protocol. */ export type PrePushRef = { localRef: string; localOid: string; remoteRef: string; remoteOid: string; }; /** The all-zero object id git uses for "no commit" (ref create/delete). */ export declare const PRE_PUSH_ZERO_OID: string; /** Parse the pre-push stdin protocol; malformed lines are ignored. */ export declare function parsePrePushRefs(stdin: string): PrePushRef[]; /** True iff `files` is non-empty and every entry is a non-render doc. An empty list * means the range diff was empty/unreadable — never treated as docs-only. */ export declare function docsOnlyFiles(files: readonly string[]): boolean; export type PrePushCaptureChoice = { /** Commit to capture and publish, or undefined when nothing can be faithfully * captured (all deletes / docs-only / only non-checked-out refs). */ sha?: string; /** Human-readable skip notes for the hook to surface on stderr. */ notes: string[]; }; /** * Choose which pushed commit (if any) the hook should capture. * * @param refs parsed stdin refspecs; empty means "no refs fed" (manual run). * @param headSha `git rev-parse HEAD`, or undefined outside a repo. * @param changedFiles list files changed from..to, or undefined when the range is * unreadable (e.g. the remote oid isn't fetched locally). */ export declare function choosePrePushCaptureSha(options: { refs: readonly PrePushRef[]; headSha: string | undefined; changedFiles: (from: string, to: string) => readonly string[] | undefined; }): PrePushCaptureChoice;