gitoria
All repositories: gitoria
4.1 KB
// lib/git-helpers.hl — what the git readers look up: path and name checks, ids, tab-separated fields, sizes, and the// commit-subject markers of pull requests (`|||PR`) and releases (`|||RL`). Statics only, git itself is not called here.import { isHex, isDigits } from './util.hl'// a path we let through: printable, no leading dash, no backslash / quote / control charactersstatic safePath = (path) => {if (path == null || path == '' || path.length > 300 || path.startsWith('-')) { return false }let i = 0while (i < path.length) {c = path.charCodeAt(i)if (c < 32 || c == 127 || c == 34 || c == 92 || c == 58) { return false }i = i + 1}return true}static safeName = (n) => { return safePath(n) && n.length <= 100 && !n.endsWith('/') && !n.includes('//') }// a URL path piece: percent-encoded, the slashes kept (encodeURIComponent is a global since hybriel #14)static enc = (s) => { return encodeURIComponent(s).replaceAll('%2F', '/') }static isHexId = (s) => { return isHex(s, 40, 4) }// tab-separated fields of a line git wrote. (split() / indexOf() do not find a tab in a line that// came from hl:proc, so scan by character code.)static tabAt = (line) => {let i = 0while (i < line.length) {if (line.charCodeAt(i) == 9) { return i }i = i + 1}return -1}static tabs = (line) => {out = []let start = 0let i = 0while (i < line.length) {if (line.charCodeAt(i) == 9) {out.push(line.slice(start, i))start = i + 1}i = i + 1}out.push(line.slice(start))return out}static sizeText = (n) => {if (n < 1024) { return n + ' B' }unit = n < 1048576 ? 1024 : 1048576t = (n * 10 - (n * 10) % unit) / unitreturn ((t - t % 10) / 10) + '.' + (t % 10) + (n < 1048576 ? ' KB' : ' MB')}// ---- the markers (pulls.hl, releases.hl) ----------------------------------------------------------// a commit subject → null (not a request) or { target: '' (= default) | name, title }static parsePull = (subject) => {if (subject == null) { return null }if (subject == '|||PR') { return { target = '' title = '' } }if (subject.startsWith('|||PR ')) { return { target = '' title = subject.slice(6).trim() } }if (subject.startsWith('|||PR|')) {close = subject.indexOf(']')if (close < 7) { return null }let target = subject.slice(6, close)rest = subject.slice(close + 1)if (rest != '' && !rest.startsWith(' ')) { return null }if (!safeName(target)) { return null }return { target = target title = rest.trim() }}return null}// the part of a version after its patch digits: only letters, digits, `.` and `-`static suffixOk = (s) => {let i = 0while (i < s.length) {c = s.charCodeAt(i)if (!((c >= 48 && c <= 57) || (c >= 65 && c <= 90) || (c >= 97 && c <= 122) || c == 45 || c == 46)) { return false }i = i + 1}return true}// `1.2.3` or `1.2.3a` → { major, minor, patch, text } or nullstatic parseVersion = (t) => {if (t == null || t.length > 32) { return null }parts = t.split('.')if (parts.length < 3) { return null }if (!isDigits(parts[0], 9) || !isDigits(parts[1], 9)) { return null }rest = parts.slice(2).join('.')let n = 0while (n < rest.length && rest.charCodeAt(n) >= 48 && rest.charCodeAt(n) <= 57) { n = n + 1 }if (n == 0 || n > 9 || !suffixOk(rest.slice(n))) { return null }return { major = toNumber(parts[0]) minor = toNumber(parts[1]) patch = toNumber(rest.slice(0, n)) text = t }}// a commit subject → null (not a release) or { kind: 'patch' | 'med' | 'mj' | 'set', version, title }static parseRelease = (subject) => {if (subject == null) { return null }if (subject == '|||RL') { return { kind = 'patch' version = null title = '' } }if (subject.startsWith('|||RL ')) { return { kind = 'patch' version = null title = subject.slice(6).trim() } }if (subject.startsWith('|||RL|')) {body = subject.slice(6)sp = body.indexOf(' ')token = sp < 0 ? body : body.slice(0, sp)let title = sp < 0 ? '' : body.slice(sp + 1).trim()if (token == 'med') { return { kind = 'med' version = null title = title } }if (token == 'mj') { return { kind = 'mj' version = null title = title } }v = parseVersion(token)if (v == null) { return null }return { kind = 'set' version = v title = title }}return null}
Branches
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