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
103 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
4import { arrange, formatBytes, installCommands, shortCount, shortDigest } from "./packages.ts";
5
6test("sizes read as registries show them", () => {
7 assert.equal(formatBytes(0), "0 B");
8 assert.equal(formatBytes(812), "812 B");
9 assert.equal(formatBytes(12_340_000), "12.3 MB");
10 assert.equal(formatBytes(1_400_000_000), "1.4 GB");
11 assert.equal(formatBytes(250_000_000), "250 MB");
12});
13
14test("digests shorten for lists", () => {
15 assert.equal(shortDigest("sha256:3f2a9c1b7d0e55aa"), "3f2a9c1b7d0e");
16});
17
18test("an npm package is installed after .npmrc names its scope's registry, and a token for private ones", () => {
19 const pkg = { ecosystem: "npm" as const, address: "g1t.sh/-/npm/@acme/ui", name: "ui", workspace: "acme" };
20 assert.deepEqual(installCommands(pkg, "1.2.0", "ada"), {
21 registry: "npm config set @acme:registry=https://g1t.sh/-/npm/",
22 login: "npm config set //g1t.sh/-/npm/:_authToken=YOUR_TOKEN",
23 install: "npm install @acme/ui@1.2.0",
24 });
25 assert.equal(installCommands(pkg, null, "ada").install, "npm install @acme/ui");
26});
27
28test("a Composer package is required after its workspace's repository is added, with credentials for private ones", () => {
29 const pkg = { ecosystem: "composer" as const, address: "g1t.sh/-/composer/acme/acme/lib", name: "acme/lib", workspace: "acme" };
30 assert.deepEqual(installCommands(pkg, "v1.1.0", "ada"), {
31 registry: "composer config repositories.acme composer https://g1t.sh/-/composer/acme/",
32 login: "composer config --global --auth http-basic.g1t.sh ada YOUR_TOKEN",
33 install: "composer require acme/lib:v1.1.0",
34 });
35});
36
Cargo on g1t.sh: a sparse registry per workspace, cargo publish/add/yank/search with a g1t token; npm rows show their version37test("a crate is added after .cargo/config.toml names its workspace's registry, with cargo login for private ones", () => {
38 const pkg = { ecosystem: "cargo" as const, address: "g1t.sh/-/cargo/acme/http-client", name: "http-client", workspace: "acme" };
39 assert.deepEqual(installCommands(pkg, "0.3.1", "ada"), {
40 registry:
41 "mkdir -p .cargo && printf '[registries.acme]\\nindex = \"sparse+https://g1t.sh/-/cargo/acme/index/\"\\ncredential-provider = \"cargo:token\"\\n' >> .cargo/config.toml",
42 login: "cargo login --registry acme",
43 install: "cargo add http-client@0.3.1 --registry acme",
44 });
45 assert.equal(installCommands(pkg, null, "ada").install, "cargo add http-client --registry acme");
46});
47
Merge branch 'worktree-agent-a6a121745e81f639f'48test("a Maven artifact is fetched from its workspace's repository, with a settings.xml server for private ones", () => {
49 const pkg = { ecosystem: "maven" as const, address: "g1t.sh/-/maven/acme/com.acme:web", name: "com.acme:web", workspace: "acme" };
50 assert.deepEqual(installCommands(pkg, "1.2.0", "ada"), {
51 login:
52 "mkdir -p ~/.m2 && [ ! -e ~/.m2/settings.xml ] && printf '<settings><servers><server><id>acme</id><username>ada</username><password>YOUR_TOKEN</password></server></servers></settings>\\n' > ~/.m2/settings.xml",
53 install: "mvn dependency:get -Dartifact=com.acme:web:1.2.0 -DremoteRepositories=acme::default::https://g1t.sh/-/maven/acme/",
54 });
55 assert.match(installCommands(pkg, null, "ada").install, /-Dartifact=com\.acme:web:LATEST /);
56});
57
58test("a NuGet package is added from its workspace's feed, named as a source with credentials for private ones", () => {
59 const pkg = { ecosystem: "nuget" as const, address: "g1t.sh/-/nuget/acme/Acme.Web", name: "Acme.Web", workspace: "acme" };
60 assert.deepEqual(installCommands(pkg, "1.0.0", "ada"), {
61 registry: "dotnet nuget add source https://g1t.sh/-/nuget/acme/v3/index.json --name acme",
62 login: "dotnet nuget update source acme --username ada --password YOUR_TOKEN --store-password-in-clear-text",
63 install: "dotnet add package Acme.Web --version 1.0.0 --source https://g1t.sh/-/nuget/acme/v3/index.json",
64 });
65 assert.equal(installCommands(pkg, null, "ada").install, "dotnet add package Acme.Web --source https://g1t.sh/-/nuget/acme/v3/index.json");
66});
67
68test("a gem is added with Bundler from its workspace's registry, with credentials for private ones", () => {
69 const pkg = { ecosystem: "rubygems" as const, address: "g1t.sh/-/rubygems/acme/hello", name: "hello", workspace: "acme" };
70 assert.deepEqual(installCommands(pkg, "0.1.0", "ada"), {
71 login: "bundle config set --global https://g1t.sh/-/rubygems/acme/ ada:YOUR_TOKEN",
72 install: "bundle add hello --version 0.1.0 --source https://g1t.sh/-/rubygems/acme/",
73 });
74 assert.equal(installCommands(pkg, null, "ada").install, "bundle add hello --source https://g1t.sh/-/rubygems/acme/");
75});
76
The docs' Copy page menu keeps its own spacing, with an icon per item77test("a container image is pulled by its address and tag", () => {
78 const pkg = { ecosystem: "container" as const, address: "g1t.sh/acme/web", name: "web", workspace: "acme" };
79 assert.deepEqual(installCommands(pkg, "latest", "ada"), {
80 login: "docker login g1t.sh -u ada",
81 install: "docker pull g1t.sh/acme/web:latest",
82 });
83 assert.equal(installCommands(pkg, null, "ada").install, "docker pull g1t.sh/acme/web");
84});
85
86test("packages are listed by the visibility and order asked for", () => {
87 const list = [
88 { name: "web", visibility: "private" as const, updated_at: "2026-10-01T00:00:00Z", downloads: 5 },
89 { name: "api", visibility: "public" as const, updated_at: "2026-10-03T00:00:00Z", downloads: 9 },
90 { name: "cli", visibility: "public" as const, updated_at: "2026-10-02T00:00:00Z", downloads: 9 },
91 ];
92 assert.deepEqual(arrange(list, "all", "updated").map((p) => p.name), ["api", "cli", "web"]);
93 assert.deepEqual(arrange(list, "all", "downloads").map((p) => p.name), ["api", "cli", "web"]);
94 assert.deepEqual(arrange(list, "all", "name").map((p) => p.name), ["api", "cli", "web"]);
95 assert.deepEqual(arrange(list, "private", "updated").map((p) => p.name), ["web"]);
96 assert.deepEqual(arrange(list, "public", "name").map((p) => p.name), ["api", "cli"]);
97});
98
99test("download counts read short", () => {
100 assert.equal(shortCount(940), "940");
101 assert.equal(shortCount(16_100), "16.1k");
102 assert.equal(shortCount(2_000_000), "2M");
103});

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