gitoria

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commita0727ca3a0727ca3ident#31: the selector's sign-in returns to the page the user started on (return attribute = the login callback with next), gate checkmrea0727ca3/lib/git-helpers.hl

4.5 KB

  1. // lib/git-helpers.hl — what the git readers look up: path and name checks, ids, tab-separated fields, sizes, and the
  2. // commit-subject markers of pull requests (`|||PR`) and releases (`|||RL`). Statics only, git itself is not called here.
  3. // a path we let through: printable, no leading dash, no backslash / quote / control characters
  4. static safePath = (path) => {
  5. if (path == null || path == '' || path.length > 300 || path.startsWith('-')) { return false }
  6. let i = 0
  7. while (i < path.length) {
  8. let c = path.charCodeAt(i)
  9. if (c < 32 || c == 127 || c == 34 || c == 92 || c == 58) { return false }
  10. i = i + 1
  11. }
  12. return true
  13. }
  14. static safeName = (n) => { return safePath(n) && n.length <= 100 && !n.endsWith('/') && !n.includes('//') }
  15. // a URL path piece: percent-encoded, the slashes kept (encodeURIComponent is a global since hybriel #14)
  16. static enc = (s) => { return encodeURIComponent(s).replaceAll('%2F', '/') }
  17. static isHexId = (s) => {
  18. if (s == null || s.length < 4 || s.length > 40) { return false }
  19. let i = 0
  20. while (i < s.length) {
  21. let c = s.charCodeAt(i)
  22. if (!((c >= 48 && c <= 57) || (c >= 97 && c <= 102))) { return false }
  23. i = i + 1
  24. }
  25. return true
  26. }
  27. // tab-separated fields of a line git wrote. (split() / indexOf() do not find a tab in a line that
  28. // came from hl:proc, so scan by character code.)
  29. static tabAt = (line) => {
  30. let i = 0
  31. while (i < line.length) {
  32. if (line.charCodeAt(i) == 9) { return i }
  33. i = i + 1
  34. }
  35. return -1
  36. }
  37. static tabs = (line) => {
  38. out = []
  39. let start = 0
  40. let i = 0
  41. while (i < line.length) {
  42. if (line.charCodeAt(i) == 9) {
  43. out.push(line.slice(start, i))
  44. start = i + 1
  45. }
  46. i = i + 1
  47. }
  48. out.push(line.slice(start))
  49. return out
  50. }
  51. static sizeText = (n) => {
  52. if (n < 1024) { return n + ' B' }
  53. unit = n < 1048576 ? 1024 : 1048576
  54. t = (n * 10 - (n * 10) % unit) / unit
  55. return ((t - t % 10) / 10) + '.' + (t % 10) + (n < 1048576 ? ' KB' : ' MB')
  56. }
  57. // ---- the markers (pulls.hl, releases.hl) ----------------------------------------------------------
  58. // a commit subject → null (not a request) or { target: '' (= default) | name, title }
  59. static parsePull = (subject) => {
  60. if (subject == null) { return null }
  61. if (subject == '|||PR') { return { target = '' title = '' } }
  62. if (subject.startsWith('|||PR ')) { return { target = '' title = subject.slice(6).trim() } }
  63. if (subject.startsWith('|||PR|')) {
  64. close = subject.indexOf(']')
  65. if (close < 7) { return null }
  66. let target = subject.slice(6, close)
  67. rest = subject.slice(close + 1)
  68. if (rest != '' && !rest.startsWith(' ')) { return null }
  69. if (!safeName(target)) { return null }
  70. return { target = target title = rest.trim() }
  71. }
  72. return null
  73. }
  74. static isDigits = (s) => {
  75. if (s == '' || s.length > 9) { return false }
  76. let i = 0
  77. while (i < s.length) {
  78. let c = s.charCodeAt(i)
  79. if (c < 48 || c > 57) { return false }
  80. i = i + 1
  81. }
  82. return true
  83. }
  84. // the part of a version after its patch digits: only letters, digits, `.` and `-`
  85. static suffixOk = (s) => {
  86. let i = 0
  87. while (i < s.length) {
  88. let c = s.charCodeAt(i)
  89. if (!((c >= 48 && c <= 57) || (c >= 65 && c <= 90) || (c >= 97 && c <= 122) || c == 45 || c == 46)) { return false }
  90. i = i + 1
  91. }
  92. return true
  93. }
  94. // `1.2.3` or `1.2.3a` → { major, minor, patch, text } or null
  95. static parseVersion = (t) => {
  96. if (t == null || t.length > 32) { return null }
  97. parts = t.split('.')
  98. if (parts.length < 3) { return null }
  99. if (!isDigits(parts[0]) || !isDigits(parts[1])) { return null }
  100. rest = parts.slice(2).join('.')
  101. let n = 0
  102. while (n < rest.length && rest.charCodeAt(n) >= 48 && rest.charCodeAt(n) <= 57) { n = n + 1 }
  103. if (n == 0 || n > 9 || !suffixOk(rest.slice(n))) { return null }
  104. return { major = toNumber(parts[0]) minor = toNumber(parts[1]) patch = toNumber(rest.slice(0, n)) text = t }
  105. }
  106. // a commit subject → null (not a release) or { kind: 'patch' | 'med' | 'mj' | 'set', version, title }
  107. static parseRelease = (subject) => {
  108. if (subject == null) { return null }
  109. if (subject == '|||RL') { return { kind = 'patch' version = null title = '' } }
  110. if (subject.startsWith('|||RL ')) { return { kind = 'patch' version = null title = subject.slice(6).trim() } }
  111. if (subject.startsWith('|||RL|')) {
  112. body = subject.slice(6)
  113. sp = body.indexOf(' ')
  114. token = sp < 0 ? body : body.slice(0, sp)
  115. let title = sp < 0 ? '' : body.slice(sp + 1).trim()
  116. if (token == 'med') { return { kind = 'med' version = null title = title } }
  117. if (token == 'mj') { return { kind = 'mj' version = null title = title } }
  118. v = parseVersion(token)
  119. if (v == null) { return null }
  120. return { kind = 'set' version = v title = title }
  121. }
  122. return null
  123. }

Branches

Latest commits

  • a0727ca3ident#31: the selector's sign-in returns to the page the user started on (return attribute = the login callback with next), gate checkmre
  • a06975f9gitoria: a gap between your name and Log out in the phone header (they touched); gate checks itmre
  • 32ba9d59gitoria: leave the host-only cookie experiment out of the browser gate (gitoria#24 is a separate mission)mre
  • 43ad2bcfgitoria header: the selector alone plus your name and Log out as before the theme missions; tests follow (WIP: host-only cookie experiment fails)mre
  • ac2c4e3fident selector back in the header (creator 2026-10-24): selector top right signed in and out on phone and desktop, no second Log in button, new gate checks (WIP: gates not re-run after the last edits)mre
  • b279f536theme: sync from layouts 4994037 (list rows stack, td word-keep, heading code, edited tap target)mre
  • 2b01515ctests/ticketskit: a failed start kills the tickets server (own process group); stop() kills the groupmre
  • 109cfc5ctests/ticketskit: keep the rotated session cookie of the tickets login (tickets ST2 session rotation)mre
  • 7eb6be27sessions last 99 years (creator 2026-10-23: logins never expire; only sign out ends them)mre
  • b3911918reports/MG-mobile.md: 404 fixed, rebased gatesMG
  • 9da65b42tests/browser.mjs: 404 checks (host, no hydration wait)MG
  • 00517fafgitoria: shell 404 page for unknown paths (catch-all route, status 404, JSON 404 under /api), 390 gate checksMG
  • d9e977f0reports/MG-mobile.md, LOGMG
  • 2f2725actests/browser.mjs: commit-row check (one row, centred date)MG
  • 4df1ea01tests/browser.mjs: MG phone checks (list first, no dead strip, one branch heading, tab grid, commit rows, PR title row, ticket columns, wrapping commands)MG
  • c52424e9gitoria mobile: repo list before the forms, 3x2 tab grid, no duplicate branch heading, ordered commit rows, aligned ticket rows, pull title on its own row, wrapping clone commands, no dead strip under formsMG
  • 3a95252dG3: cache parsed README blocks by sha256 of the text (bounded LRU), reportmre
  • 570138cddeploy: security gate (tests/security.mjs)mre
  • da6b20fcgitoria SG: security audit fixes (uploadMax 0, Secure cookie on https, session rotation at login, nosniff on function routes, no identity in page data) + tests/security.mjs gate + reportmre
  • f98c981fgitoria B1: report wordingmre