gitoria

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit19bc1df819bc1df8gitoria#22: all repo pages under ONE layout level (components/repo.hl, hl:web D-CHAIN): a tab click replaces only the page in the slot; head and tab nav stay the same DOM nodesmre19bc1df8/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

  • 19bc1df8gitoria#22: all repo pages under ONE layout level (components/repo.hl, hl:web D-CHAIN): a tab click replaces only the page in the slot; head and tab nav stay the same DOM nodesmre
  • 40658417tests/browser.mjs: wait for the page to be live (hydrated) before clicking Merge — a click on the server-rendered button before the client mounted was lost (flaky 'Clashing change' under load)mre
  • 48a6154bre-vendor Hybriel 5406d146 (hl:web batches 9+10: #72 emits while the socket is closed delivered after reconnect, browser boot linear, faster list appends; contains int 6–14 + m406)mre
  • e972e8d7tests: short-id-switch (GITORIA_SWITCH_IDENT_PORT/_PORT) and ssh tunnel (GITORIA_GATE_TUNNEL_PORT) ports from env, defaults unchangedmre
  • f06f5349re-vendor Hybriel 6f8a0689 (int 6–11: streaming cursors, #203 index heal + close() fix, fd403 listDir/cursor fds, hl:time browser side, hl:web batches 5+6)mre
  • c7d3cc87docker-compose: nofile 65536 (Hybriel int 6+ boot opened >1024 files in the tracker)mre
  • f0e7ff8cdeploy: backup copies index files first and *.mpack data last (hot-copy skew, hybriel #203)mre
  • fe5f707cgitoria 010: report, mission, comment on why current = true staysmre
  • 9705ca86gitoria 010: gate: menu marker in the server HTMLmre
  • 8cff663agitoria 010: main-menu.hl from layouts 0bcc629 (route marker)mre
  • 359c79f7gitoria 010: re-vendor Hybriel master f9614007 (plugins whole, bin/ git-ignored)mre
  • 6bd7fb3cgitoria 009: theme re-copied from layouts 76f99f6 (menu marks the current page), current = true on the menu item, e2e marker checks, reportmre
  • 44de915cidentkit: refuse a taken ident port, cold-start deadline, abort on dead ident, clear no-code error (as notes)mre
  • 2bf5343egitoria 007: theme re-copied from layouts dbe3de7 (44 px taps), redundant tap overrides dropped, crumbs class, real-browser walk test, reportmre
  • 18843648deploy.sh: a gate without a 'passed,' line (check-theme) no longer ends the script silently (grep under pipefail) — print check-theme's summary, as layouts doesmre
  • e6dff0cbgitoria#23: report 005, STATUS, LOGmre
  • 7f992d62gitoria#23: phone first on the shared theme — brand, branch and pull links 44 px, readme code 14 px; gate block "phone first" (15 pages at 390 + the three dropdowns, fails 20 on old), dropdown-aware login/logout clicks, check-theme in GATESmre
  • a2a840a5gitoria#23 WIP (quota stop): theme from layouts, styles inherit it, shell on the theme's header/menus/sidebar, phone measurement script; gates not runmre
  • 12b665b0mission brief 005mre
  • b680c483Revert "gitoria#22: RepoTabs wrapping component for the repo tabs (active tab, no content for a missing repo)"mre