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
161 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.

The docs' Copy page menu keeps its own spacing, with an icon per item1import assert from "node:assert/strict";
2import { test } from "node:test";
3
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb974import {
5 KIND_CHOICES,
6 KIND_CHOICE_SETS,
7 bare,
8 choiceOf,
9 hasRelease,
10 kindLabel,
11 latestTag,
12 libraryPackages,
13 neverDeploys,
14 primaryLink,
Merge branch 'rm-orgchart-getstarted'15 projectPlan,
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb9716 projectChanges,
17 linksFromForm,
18 linksToShow,
19 packageLine,
20 packagePath,
21 publishGuide,
22} from "./project-kind.ts";
The docs' Copy page menu keeps its own spacing, with an icon per item23
24const pkg = (over: Record<string, unknown>) => ({
25 ecosystem: "composer" as const,
26 name: "psr/log",
27 workspace: "flagon-io",
28 latest: "3.0.2",
29 versions: 3,
30 updated_at: "2026-10-01T00:00:00Z",
31 ...over,
32});
33
34test("a package reads as its registry, its name and its latest version", () => {
35 assert.equal(packageLine(pkg({})), "Composer · psr/log 3.0.2");
36 assert.equal(packageLine(pkg({ ecosystem: "npm", name: "ui", latest: null })), "npm · @flagon-io/ui");
37 assert.equal(packagePath(pkg({})), "/flagon-io/-/packages/composer/psr/log");
38});
39
40test("what a library publishes comes before an image, released ones first", () => {
41 const list = [
42 pkg({ ecosystem: "container", name: "img", updated_at: "2026-10-05T00:00:00Z" }),
43 pkg({ name: "empty", versions: 0, updated_at: "2026-10-04T00:00:00Z" }),
44 pkg({}),
45 ];
46 assert.deepEqual(libraryPackages(list).map((p) => p.name), ["psr/log", "empty", "img"]);
47 assert.equal(hasRelease(list), true);
48 assert.equal(hasRelease([pkg({ versions: 0 })]), false);
49 assert.equal(hasRelease([]), false);
50});
51
52test("each ecosystem links to how it publishes", () => {
53 assert.equal(publishGuide("composer")?.guide, "https://docs.g1t.sh/guides/composer/");
54 assert.equal(publishGuide("composer")?.start, "git tag v1.0.0 && git push --tags");
55 assert.equal(publishGuide("npm")?.start, "npm publish");
56 assert.equal(publishGuide("go")?.guide, "https://docs.g1t.sh/guides/go/");
57 assert.equal(publishGuide("python")?.guide, "https://docs.g1t.sh/guides/packages/");
58 assert.equal(publishGuide(null), null);
59});
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb9760
61test("each choice sets a kind and where it runs, and reads back", () => {
62 for (const choice of KIND_CHOICES) {
63 const set = KIND_CHOICE_SETS[choice.value];
64 const setting = { kind: set.kind === "auto" ? null : set.kind, runs: set.runs === "auto" ? null : set.runs };
65 assert.equal(choiceOf(setting), choice.value);
66 }
67 // Set through the API to an app, with where it runs left open: no choice says that.
68 assert.equal(choiceOf({ kind: "app", runs: null }), null);
69});
70
71test("a project's badge says what it is and where it runs", () => {
72 assert.equal(kindLabel({ kind: "app", runs: "elsewhere" }), "App, deployed elsewhere");
73 assert.equal(kindLabel({ kind: "app", runs: "g1t" }), "App on g1t");
74 assert.equal(kindLabel({ kind: "app", runs: null }), "App");
75 assert.equal(kindLabel({ kind: "tool", runs: null }), "Tool");
76 assert.equal(kindLabel({ kind: "other", runs: null }), "Project");
77});
78
79test("links show homepage, docs, then the rest, never twice", () => {
80 const links = {
81 homepage: "https://g1t.sh/",
82 homepageInherited: false,
83 docs: "https://docs.g1t.sh",
84 custom: [
85 { label: "Status", url: "https://status.g1t.sh" },
86 { label: "Docs again", url: "http://docs.g1t.sh/" },
87 ],
88 };
89 assert.deepEqual(
90 linksToShow(links).map((link) => [link.type, link.label]),
91 [
92 ["homepage", "g1t.sh"],
93 ["docs", "Docs"],
94 ["custom", "Status"],
95 ],
96 );
97 // Production's address already shows on the page: the homepage pointing there is left out.
98 assert.deepEqual(linksToShow(links, ["https://g1t.sh"]).map((link) => link.type), ["docs", "custom"]);
99 assert.equal(bare("https://g1t.sh/docs/"), "g1t.sh/docs");
100});
101
102test("an overview form changes only what it carries", () => {
103 const kind = new FormData();
104 kind.set("choice", "elsewhere");
105 kind.set("productionUrl", "g1t.sh");
106 assert.deepEqual(projectChanges(kind), { kind: "app", runs: "elsewhere", productionUrl: "g1t.sh" });
107 const about = new FormData();
108 about.set("description", "");
109 about.set("homepage", "https://g1t.sh");
110 about.set("links", "rows");
111 // Every row removed: the list is cleared, not left as it was.
112 assert.deepEqual(projectChanges(about), { description: "", homepage: "https://g1t.sh", links: [] });
113 const bogus = new FormData();
114 bogus.set("choice", "sometimes");
115 assert.deepEqual(projectChanges(bogus), {});
116});
117
118test("the latest release is the newest tag by its commit", () => {
119 assert.deepEqual(
120 latestTag([
121 { name: "v1.0.0", commit: { authoredAt: "2026-09-01T00:00:00Z" } },
122 { name: "v1.1.0", commit: { authoredAt: "2026-10-01T00:00:00Z" } },
123 { name: "nightly", commit: null },
124 ]),
125 { name: "v1.1.0", at: "2026-10-01T00:00:00Z" },
126 );
127 assert.equal(latestTag([]), null);
128});
129
130test("cards show production, else the homepage or docs", () => {
131 const links = { homepage: "https://acme.dev", homepageInherited: false, docs: "https://docs.acme.dev", custom: [] };
132 assert.equal(primaryLink({ runs: "g1t", productionUrl: null, links }, "https://web-acme.g1t.page"), "https://web-acme.g1t.page");
133 assert.equal(primaryLink({ runs: "elsewhere", productionUrl: "https://app.acme.dev", links }, null), "https://app.acme.dev");
134 assert.equal(primaryLink({ runs: null, productionUrl: null, links }, null), "https://acme.dev");
135 assert.equal(primaryLink({ runs: null, productionUrl: null, links: { ...links, homepage: null } }, null), "https://docs.acme.dev");
136 assert.equal(neverDeploys({ setting: { kind: "tool", runs: null } }), true);
137 assert.equal(neverDeploys({ setting: { kind: "docs", runs: null } }), false);
138});
139
140test("custom links are read from a form's rows, blank rows left out", () => {
141 const form = new FormData();
142 for (const [label, url] of [["Status", "status.g1t.sh"], ["", ""], ["", "npmjs.com/x"]]) {
143 form.append("linkLabel", label!);
144 form.append("linkUrl", url!);
145 }
146 assert.deepEqual(linksFromForm(form), [
147 { label: "Status", url: "status.g1t.sh" },
148 { label: "", url: "npmjs.com/x" },
149 ]);
150});
Merge branch 'rm-orgchart-getstarted'151
152test("only what g1t deploys leads with production", () => {
153 assert.equal(projectPlan({ kind: "app", runs: "g1t" }), "production");
154 assert.equal(projectPlan({ kind: "docs", runs: "g1t" }), "production");
155 assert.equal(projectPlan({ kind: "app", runs: "elsewhere" }), "elsewhere");
156 assert.equal(projectPlan({ kind: "app", runs: null }), "unknown");
157 assert.equal(projectPlan({ kind: "tool", runs: null }), "release");
158 assert.equal(projectPlan({ kind: "library", runs: null }), "release");
159 assert.equal(projectPlan({ kind: "docs", runs: "elsewhere" }), "docs");
160 assert.equal(projectPlan({ kind: "other", runs: null }), "other");
161});

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