Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

g1t.sh
39 linesCodeBlameRaw

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily1/**
2 * A commit message's parts: its subject, the prose of its body, and the
3 * trailers git and tools add at the end (`Co-Authored-By: …`), which read
4 * better as metadata than as prose.
5 */
6export type CommitMessage = {
7 subject: string;
8 body: string;
9 /** The names in `Co-Authored-By` trailers, without their addresses. */
10 coAuthors: string[];
Merge commit authors and hovercards: commits show their accounts, every name opens a card (repos 0016)11 /** Every other trailer, as written but for any email address in it. */
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily12 trailers: { key: string; value: string }[];
13};
14
15const TRAILER = /^([A-Za-z][A-Za-z0-9-]*):\s+(.+)$/;
16
17export function parseCommitMessage(message: string): CommitMessage {
18 const [subject = "", ...rest] = message.split("\n");
19 const lines = rest.join("\n").trim().split("\n");
20 // Trailers are the last paragraph, when every line of it is one.
21 const lastBreak = lines.lastIndexOf("");
22 const last = lines.slice(lastBreak + 1);
23 const isTrailers = last.length > 0 && last.every((line) => TRAILER.test(line.trim()));
24 const prose = isTrailers ? lines.slice(0, Math.max(lastBreak, 0)) : lines;
25 const coAuthors: string[] = [];
26 const trailers: { key: string; value: string }[] = [];
27 if (isTrailers) {
28 for (const line of last) {
29 const [, key, value] = TRAILER.exec(line.trim())!;
30 if (key.toLowerCase() === "co-authored-by") coAuthors.push(value.replace(/\s*<[^>]*>\s*$/, "").trim());
Merge commit authors and hovercards: commits show their accounts, every name opens a card (repos 0016)31 else {
32 // `Signed-off-by: Ada <ada@example.com>` shows Ada: g1t never shows an address.
33 const shown = value.replace(/\s*<[^<>]*@[^<>]*>/g, "").trim();
34 if (shown) trailers.push({ key, value: shown });
35 }
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily36 }
37 }
38 return { subject, body: prose.join("\n").trim(), coAuthors, trailers };
39}

This file's history is long; its oldest lines are credited to the oldest commit read.