gitoria
All repositories: gitoria
2.4 KB
// lib/orgs.hl — ORGANIZATIONS (ticket gitoria#34, GO34). An organization is a name that is its own address <org>.<domain>; its repos live at// <org>.<domain>/<repo> and look like a repo page on <repo>.<domain>. One hl:mpackdb table, storage/mpackdb/orgs.db:// pk @id index !slug, owner { slug, owner (users @id), priv (true = every repo of it is private, also new ones), created }// An organization's name and a repo's name share one namespace (both are subdomains): lib/repos.hl checks both. Who belongs to an// organization is the one member list of lib/members.hl. Statics only; no page code.import { MPackDB } from 'hl:mpackdb'import { now } from 'hl:time'import { storageDir, firstOf, slugOfHost } from './util.hl'static orgsTable = new MPackDB(file = storageDir + '/orgs.db', primaryKey = '@id', indexes = ['!slug', 'owner'])static orgBySlug = (slug) => {if (slug == null || hlTypeName(slug) != 'String' || slug == '') { return null }return firstOf(orgsTable.find('slug', slug))}static putOrg = (slug, owner, priv) => {id = orgsTable.put({ slug = slug owner = owner priv = priv created = now() })return id == null ? null : orgsTable.fetch(id)}static setOrgPriv = (o, priv) => {orgsTable.update(o.id, { id = o.id slug = o.slug owner = o.owner priv = priv created = o.created })after = orgsTable.fetch(o.id)return after != null && after.priv == priv}// every organization recordstatic allOrgs = () => {all = orgsTable.find(null, null)return all == null || all.length == null ? [] : all}// THE REPO NAME OF A REQUEST: `host` (no port) and `orepo` (the first path segment of an organization's address, '' elsewhere).// '' = the main address; `name` = a repo's own address; `org/name` = a repo inside an organization; '!x' = a path that names// no repo (a first segment on a host that is not an organization) — "No such repository".static slugOfRequest = (host, orepo) => {label = slugOfHost(host)if (orepo == null || orepo == '') { return label }if (label != '' && orgBySlug(label) != null) { return label + '/' + orepo }return '!'}// the first path segment of an organization's address (the repo inside it), '' on every other host or at the organization's rootstatic orepoOfPath = (host, path) => {label = slugOfHost(host)if (label == '' || path == null || orgBySlug(label) == null) { return '' }rest = path.startsWith('/') ? path.slice(1) : pathi = rest.indexOf('/')return i < 0 ? rest : rest.slice(0, i)}
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
- 477d7bdcMerge branch 'p50'mre
- 00efc06fP50 reportmre
- e3f85afblog: commit mention slipmre
- 4d1a4cf4log: #25 numbersmre
- 1af0a60ddocs: H25 run() correctionmre
- eefa2dbcRepo setting: refuse direct pushes to the main branch (pre-receive over HTTPS and ssh)mre
- 8c8ba2f1log: PR flow announcedmre
- fa00cd35log: Kunibert pings provenmre
- 3a68cfaclog: components decisionmre
- 87de8e31log: Kunibert connected to 9 app reposmre
- c22aff69log: PR-only rollout startedmre
- 25309981log: STOP and paused workers 2026-11-08mre
- 5286803alog: worker briefs and reports of 2026-11-08mre
- 85c86605log: 2026-11-08 Arachne on list shapemre
- cb634512log: 2026-11-08 keyed lists livemre
- 07c98d4aLists: keyed rows with @id, remove(id) and one whole-list assignment instead of hand-rebuilt loopsmre
- 0db0d81elog: 2026-11-08 day52 live, W30 startedmre
- b05f6d92tests/status: the gate's 3 s app token expired during the restart; it lives 60 s like status-keyedmre
- 1e8f4f0avendor: Hybriel set-day52 (fault-path leak fix #335, keyed rows #331)mre
- f5f0fb7blog: 2026-11-08 day50/#29 live, H25 correction, V52 startedmre