gitoria

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit44de915c44de915cidentkit: refuse a taken ident port, cold-start deadline, abort on dead ident, clear no-code error (as notes)mre44de915c/components/pulls.hl

3.9 KB

  1. // components/pulls.hl — THE PULL REQUESTS of a repo (gitoria#11, gitoria#16): `/pulls` on <slug>.<domain>, its
  2. // own route. The repo head is rendered on the server from the request's host. The list comes from git (the
  3. // commits whose message starts with |||PR) on the SERVER too
  4. // (lib/pulls.hl pullsNow — hl:proc run() waits, hybriel#80): it is in the first HTML and in every hl:web navigation.
  5. parent './main.hl'
  6. import { siteName } from '../project.hl'
  7. import RepoHead from './repohead.hl'
  8. import { slugOfHost } from '../lib/util.hl'
  9. import { userOfSession } from '../lib/users.hl'
  10. import { repoAt, ownsRepo } from '../lib/repos.hl'
  11. import { pageTitle } from '../lib/repos-helpers.hl'
  12. import { pullsNow, mergePullNow, withMerge, pullsView } from '../lib/pulls.hl'
  13. import { withPullParts } from '../lib/tickets-helpers.hl'
  14. import { notifyPush } from '../lib/tickets.hl'
  15. host = null
  16. session = null
  17. slug = slugOfHost(host)
  18. repo = repoAt(slug)
  19. hasRepo = repo != null
  20. isOwner = repo != null && ownsRepo(slug, session)
  21. mergeError = ''
  22. got = repo != null ? pullsNow(slug, repo.branch) : null
  23. pullsShown = got != null && !got.isMessage
  24. pullsMessage = got != null && got.isMessage
  25. pullsText = got != null && got.isMessage ? got.message : ''
  26. pullsNone = got != null && !got.isMessage && got.noPulls
  27. pullsList = got != null && !got.isMessage ? withPullParts(withMerge(got.pulls, isOwner), repo.ticketsProject) : []
  28. pullsDefault = got != null && !got.isMessage ? got.defaultName : ''
  29. __title = pageTitle(siteName, slug, 'Pull requests')
  30. View {
  31. repoPage {
  32. RepoHead { }
  33. if (hasRepo) {
  34. repoPulls { id = "pulls"
  35. if (pullsMessage) { p { id = "pullsmessage" class = "empty" pullsText } }
  36. if (pullsShown) {
  37. p { id = "pullshelp" class = "muted" "A commit whose message starts with " code { "|||PR " } " opens a pull request; " code { "|||PR|branch] " } " sets the target (now: " strong { pullsDefault } " by default)." }
  38. if (pullsNone) { p { id = "nopulls" class = "empty" "No pull request yet." } }
  39. p { id = "mergeerror" class = "message" mergeError }
  40. ol { id = "pulllist"
  41. for (pr of pullsList) {
  42. li {
  43. span { class = "subject" for (pt of pr.parts) { if (pt.isText) { a { href = pr.href pt.text } } if (pt.isLink) { a { class = "ticketref" href = pt.href pt.text } } } }
  44. span { class = pr.state pr.state }
  45. span { class = "branches"
  46. if (pr.hasSource) { a { class = "source" href = pr.sourceHref pr.source } }
  47. if (pr.noSource) { span { class = "source muted" "(branch gone)" } }
  48. span { class = "muted" "→" }
  49. if (pr.targetLinked) { a { class = "target" href = pr.targetHref pr.target } }
  50. if (pr.targetMissing) { span { class = "target muted" pr.target " (no such branch)" } }
  51. }
  52. span { class = "muted" pr.author }
  53. time { pr.date }
  54. button { class = pr.mergeClass type = "button" value = pr.sha "Merge" on click(e) { emit mergePull(e.target.value) } }
  55. }
  56. }
  57. }
  58. }
  59. }
  60. }
  61. }
  62. }
  63. // "Merge" (the owner, only when clicked): the face merges and answers with the list read again
  64. on mergePull(sha) {
  65. mergeError = ''
  66. r = emit server gitoriaMergePull(slug, sha)
  67. if (r == null || r.error != null) {
  68. mergeError = r != null ? r.error : 'could not merge'
  69. return null
  70. }
  71. got = r.result
  72. pullsList = r.list
  73. pullsNone = got.noPulls
  74. }
  75. on server gitoriaMergePull(slugOf, sha, session) {
  76. if (session == null || repoAt(slugOf) == null) { return { error = 'could not merge' } }
  77. u = userOfSession(session)
  78. if (u == null || !ownsRepo(slugOf, session)) { return { error = 'only the owner can merge a pull request' } }
  79. r = mergePullNow(slugOf, repoAt(slugOf).branch, sha, u.name)
  80. if (r.error != null) { return { error = r.error } }
  81. notifyPush(slugOf, false)
  82. // the list again, with its ticket links made here: tickets-helpers.hl reads the environment, which the browser has not
  83. return pullsView(slugOf, repoAt(slugOf).branch, true, repoAt(slugOf).ticketsProject)
  84. }

Branches

Latest commits

  • 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
  • 4fda244fgitoria#22: RepoTabs wrapping component for the repo tabs (active tab, no content for a missing repo)mre
  • 0fd5e280mission brief 004mre
  • e1d425e7paths: projects moved into /media/STORAGE/projects/WorldAPI/mre
  • e59ff114deploy.sh: wait up to DEPLOY_URL_WAIT (120 s) for 200 after the restart, as the other apps (cold compile, hybriel#148)mre
  • bcafcceb003: compose cache volume + tmpfs /tmp, gate start waits 120 s, report/LOG/STATUSmre
  • bed3f2d5Re-vendor Hybriel to the shared static build 0f396652 (plugins; bin/ is git-ignored)mre
  • 3207e128mission brief 003mre
  • 18ab71fbtests/ticketskit: wait up to 120 s for tickets (native Hybriel cold compile ~25 s, hybriel#148)mre
  • 4fffa966docker-compose: init: true (hybriel#156, PID 1 ignored SIGTERM, every restart waited 10 s)mre
  • 4f47843egate: ticket links use the tickets short URL (/<slug>/<n>, tickets#25)mre
  • 86605446mission 002 (code order) 4/4: README file map + import order + 'Same output' test + gate run with a tickets HEAD copy, STATUS (entry, lessons), LOG, report; tests/realdata-baseline.mjs + realdata-compare.py (a cleanup answers the same on live data: pages, modules, API, git over HTTPS and SSH, faces), tests/letcount.pymre
  • cc7bf7bamission 002 (code order) 3/4: let only where a variable is reassigned or re-bound in a loop body (289 lets → plain declarations; 213 left: 125 reassigned, 88 loop-bound; no member/import/param clash). gates 200/0, 46/0, 44/0; real-data reads + writes identical (browser modules: var → const only)mre