Skip to content
43 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.

One kind of access token; presence and status; usernames keep their case; the tour is a miniature of the real app; icons for password managers1import assert from "node:assert/strict";
2import { test } from "node:test";
3
A workflow's `uses: actions/setup-node@v4` means GitHub's `actions` again, whoever is on g1t. g1t looked for a repository on g1t before GitHub, and anyone could make a public workspace called `actions`, `docker` or `aws-actions` and have its `setup-node` run in every workflow that names GitHub's, with that job's secrets. Now another workspace's public repository answers only for a name GitHub has no public repository of; the caller's own workspace and g1t's own `g1t/…` still answer from g1t, and when GitHub can't be asked, GitHub's is used. The names of the GitHub accounts whose actions workflows use most can no longer be registered, renamed to, or taken by signing up with GitHub (which suggests the name with `-gh`); an account that has one keeps it, and mentions and invitations still find it. The Actions, authentication and workspaces guides say so.4import { USERNAME_PATTERN, canonicalUsername, isActionOwnerName, isClaimableName, isReservedName, isValidNamespace, isValidUsername, shownUsername } from "./names.ts";
One kind of access token; presence and status; usernames keep their case; the tour is a miniature of the real app; icons for password managers5
6test("usernames take letters of either case, digits and single hyphens, up to 39", () => {
7 for (const good of ["ana", "Ana", "ANA-Lopez", "a", "A1", "x".repeat(39)]) assert.ok(isValidUsername(good), good);
8 for (const bad of ["", "-Ana", "Ana-", "An--a", "An_a", "Ana.B", "Ana B", "x".repeat(40), "Ána"]) assert.ok(!isValidUsername(bad), bad);
9});
10
11test("reserved names are reserved in any case", () => {
12 for (const name of ["G1T", "G1t-Agent", "Ghost", "Settings", "API"]) {
13 assert.ok(isReservedName(name), name);
14 assert.ok(!isValidUsername(name), name);
15 }
16});
17
18test("a username is found lowercased and shown as written", () => {
19 assert.equal(canonicalUsername(" Ana-Lopez "), "ana-lopez");
20 assert.equal(shownUsername({ username: "ana", display_username: "Ana" }), "Ana");
21 assert.equal(shownUsername({ username: "ana", displayUsername: "ANA" }), "ANA");
22 assert.equal(shownUsername({ username: "ana" }), "ana");
23 // A display form that is some other name is never shown.
24 assert.equal(shownUsername({ username: "ana", display_username: "Bob" }), "ana");
25 // Workspace slugs stay lowercase.
26 assert.ok(!isValidNamespace("Acme"));
27});
28
29test("the form's pattern says what the rule says", () => {
30 const pattern = new RegExp(`^(?:${USERNAME_PATTERN})$`);
31 for (const name of ["Ana", "ana-lopez", "A1"]) assert.ok(pattern.test(name), name);
32 for (const name of ["-ana", "ana-", "an--a", "an_a"]) assert.ok(!pattern.test(name), name);
33});
A workflow's `uses: actions/setup-node@v4` means GitHub's `actions` again, whoever is on g1t. g1t looked for a repository on g1t before GitHub, and anyone could make a public workspace called `actions`, `docker` or `aws-actions` and have its `setup-node` run in every workflow that names GitHub's, with that job's secrets. Now another workspace's public repository answers only for a name GitHub has no public repository of; the caller's own workspace and g1t's own `g1t/…` still answer from g1t, and when GitHub can't be asked, GitHub's is used. The names of the GitHub accounts whose actions workflows use most can no longer be registered, renamed to, or taken by signing up with GitHub (which suggests the name with `-gh`); an account that has one keeps it, and mentions and invitations still find it. The Actions, authentication and workspaces guides say so.34
35test("well-known GitHub action owners cannot be claimed, but stay valid names", () => {
36 for (const name of ["actions", "Docker", " aws-actions "]) {
37 assert.ok(isActionOwnerName(name), name);
38 assert.ok(!isValidUsername(name), name);
39 }
40 assert.ok(!isClaimableName("actions"));
41 assert.ok(isValidNamespace("actions"));
42 assert.ok(isClaimableName("actions-team"));
43});