Open History to see the last commit
1import { trimAsciiWhitespace } from "@t3tools/contracts";
2
3// `--short` and `--abbrev-ref` print `heads/<name>` when a tag shares the branch's name, so
4// branch reads take the full ref and strip the prefix themselves.
5export function branchNameFromHeadRef(value: string): string | null {
6 const ref = trimAsciiWhitespace(value);
7 return ref.startsWith("refs/heads/") && ref.length > "refs/heads/".length
8 ? ref.slice("refs/heads/".length)
9 : null;
10}