gitoria
All repositories: gitoria
5.5 KB
// lib/repos-helpers.hl — what lib/repos.hl looks up: the slug's rules, the row a page shows, a whole record with some// fields changed, the tab title, the Markdown read view of the API. Statics only, no table access.import { NL, isDigit, localStamp, repoOrigin } from './util.hl'import { nameOfUser } from './users.hl'// names that are addresses of the system itself, or that would read as one (never a repo)// only technical host names; the creator's own apps (ident, tickets, hybriel, …) are repos here too (creator 2026-09-25)static reserved = ['www' 'api' 'git' 'ssh' 'http' 'https' 'ftp' 'mail' 'smtp' 'imap' 'admin' 'root' 'cdn' 'static' 'assets' 'login' 'logout' 'new' 'repos']static isLower = (c) => { return c >= 97 && c <= 122 }// the slug's rules → null (fine) or the complaint. A DNS label: 2–40 characters, a–z 0–9 and// single hyphens, starting and ending with a letter or digit ("--" is refused: xn-- is punycode)static slugError = (slug) => {if (slug == null || hlTypeName(slug) != 'String') { return 'the address must be text' }if (slug.length < 2 || slug.length > 40) { return 'the address must have 2–40 characters' }let i = 0while (i < slug.length) {c = slug.charCodeAt(i)ok = isLower(c) || isDigit(c) || (c == 45 && i > 0 && i < slug.length - 1)if (!ok) { return 'the address may only have lowercase letters a–z, digits and hyphens, and starts and ends with a letter or digit' }i = i + 1}if (slug.includes('--')) { return 'the address must not have two hyphens in a row' }if (reserved.includes(slug)) { return "'" + slug + "' is reserved for the system" }return null}// names an organization's repo may not have: its address would collide with a page of the organization's addressstatic orgReserved = ['code' 'branch' 'commit' 'pulls' 'releases' 'tickets' 'settings' 'api' 'login' 'icons' '__git' '__hl' 'favicon' 'favicon.ico']// the rules for a repo's full name: `name` (slugError) or `org/name` (both parts valid, the repo name not a page word)static fullNameError = (full) => {if (full == null || hlTypeName(full) != 'String') { return 'the address must be text' }i = full.indexOf('/')if (i < 0) { return slugError(full) }bad = slugError(full.slice(0, i))if (bad != null) { return bad }name = full.slice(i + 1)bad2 = slugError(name)if (bad2 != null) { return bad2 }if (orgReserved.includes(name)) { return "'" + name + "' is reserved inside an organization" }return null}// what a page and the API show of a repo (never the tickets key); `eff` = the repo is private (its own flag or its organization's)static rowOf = (r, eff) => {org = r.org != null ? r.org : ''return { id = r.id @id = r.id slug = r.slug org = org inOrg = org != '' isPrivate = eff isPublic = !eff description = r.description described = r.description != '' owner = nameOfUser(r.owner) branch = r.branch != null ? r.branch : '' ticketsOn = r.tktKey != null && r.tktKey != '' ticketsOff = r.tktKey == null || r.tktKey == '' ticketsProject = r.tktProject != null ? r.tktProject : '' ticketsTitle = r.tktTitle != null ? r.tktTitle : '' created = localStamp(r.created) createdMs = r.created address = repoOrigin(r.slug) + '/' }}// a repo's whole record with some fields changed (update() replaces the record: every field must be given again)static withChange = (r, change) => {o = { id = r.id slug = r.slug description = r.description owner = r.owner created = r.created branch = r.branch != null ? r.branch : '' tktKey = r.tktKey != null ? r.tktKey : '' tktProject = r.tktProject != null ? r.tktProject : '' tktTitle = r.tktTitle != null ? r.tktTitle : '' tktApi = r.tktApi != null ? r.tktApi : '' org = r.org != null ? r.org : '' priv = r.priv == true protect = r.protect == true }for (k of change.keys()) { o[k] = change[k] }return o}// the repo tab a path belongs to (components/repo.hl marks it): '/' readme · code/branch/commit pages 'code' · pulls · releases ·// tickets · settings, else ''. `String path`: since the purity contracts (Hybriel missions 575-578, in set-day48) only a typed parameter proves `startsWith` pure, so the browser// re-derives the tab after a navigation (an untyped one left the Readme tab marked: V48, SPEC purity rules)static tabOfPath = (String path) => {if (path == '' || path == '/') { return 'readme' }if (path == '/code' || path.startsWith('/code/') || path.startsWith('/branch/') || path.startsWith('/commit/')) { return 'code' }if (path == '/pulls' || path.startsWith('/pulls/')) { return 'pulls' }if (path == '/releases') { return 'releases' }if (path == '/tickets') { return 'tickets' }if (path == '/settings') { return 'settings' }return ''}// a tab title: 'Code · alpha · gitoria', 'alpha · gitoria', 'gitoria'static pageTitle = (site, slug, what) => {t = slug != null && slug != '' ? slug + ' · ' + site : sitereturn what != null && what != '' ? what + ' · ' + t : t}// ---- the Markdown read view (Accept: text/markdown) — for LLM readers ---------------------------static repoDocument = (row) => {let out = '# ' + row.slug + NL + NLif (row.described) { out = out + row.description + NL + NL }out = out + '- address: ' + row.address + NL + '- owner: ' + row.owner + NL + '- created: ' + row.created + NLreturn out}static listDocument = (rows) => {let out = '# Repositories (' + rows.length + ')' + NL + NLif (rows.length == 0) { out = out + 'No repository yet.' + NL }for (r of rows) { out = out + '- [' + r.slug + '](' + r.address + ')' + (r.described ? ' — ' + r.description : '') + NL }return out}
Branches
- f1-broken-json
- f2-api-bugs
- gp-gate-ports
- heap-revert
- hl25-records
- ident-chooser-selector
- mainmain branch
- p51-public-pr-reads
- records-1112
- s25-no-session-on-login-error
- v59
- w52-person-approval
- w52b-approval-followup
- w52c-header-phone
- w53-pulls-speed-pr
- w54-repo-rename-pr
- w55-rename-org
- w56-owner-members
- w62-pr-close
- w63-force-push
- w64-org-slash
Latest commits
- 26117255|||PR apps API: review comments on files with spaces in their namemre
- b8796cecMerge branch 'f1-broken-json' into mainGitoria
- 2f2959c5|||PR apps API: broken JSON body gives 400 invalid_json, not 500mre
- f7c6ca07Merge branch 'ident-chooser-selector' into mainGitoria
- 691abb8e|||PR tests: find ident identity choice without the removed .choose classmre
- 16a3530fMerge branch 'heap-revert' into mainGitoria
- 220a80e0|||PR Remove temporary /__heap route and heap helper; logmre
- 13f0c342Merge branch 'hl25-records' into mainGitoria
- a002ecb7|||PR records: HL25 report, heap helper, logmre
- 2492a55cTemporary keyed /__heap route for the live memory snapshotmre
- fefaedd2log: tracker PR-only, HL25 startedmre
- 21aa57calog: parkmre
- e9f950a8reports: G25c soakmre
- a7783686log: deploy 9f41ffcmre
- 9f41ffc1log: W30b mergedmre
- bef635c1Merge branch 'w30b'mre
- 15b996a5Org list: keyed rows by @id, newest first, concat instead of hand loopmre
- c4f6d9e3reports: G25c growth huntmre
- b88e39f1log: privacy cleanup donemre
- bfd7826ddocs: neutral example organisation namemre