gitoria

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit5d2c385a5d2c385agitoria: the sign-in callback keeps the session it finds and signs it in (same cookie, nothing signed out; ident#28); security gate 71+5 failing → 76 passed; deploy.sh runs tests/private.mjs toomre5d2c385a/components/pulls.hl

4.0 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 './repo.hl'
  6. import { siteName } from '../project.hl'
  7. import { slugOfRequest } from '../lib/orgs.hl'
  8. import { userOfSession } from '../lib/users.hl'
  9. import { titleSlug, repoAt, ownsRepo } from '../lib/repos.hl'
  10. import { pageTitle } from '../lib/repos-helpers.hl'
  11. import { pullsNow, mergePullNow, withMerge, pullsView } from '../lib/pulls.hl'
  12. import { withPullParts } from '../lib/tickets-helpers.hl'
  13. import { notifyPush } from '../lib/tickets.hl'
  14. host = null
  15. orepo = ''
  16. session = null
  17. slug = slugOfRequest(host, orepo)
  18. repo = repoAt(slug, session)
  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, titleSlug(host, orepo, session), 'Pull requests')
  30. View {
  31. repoPage {
  32. if (hasRepo) {
  33. repoPulls { id = "pulls"
  34. if (pullsMessage) { p { id = "pullsmessage" class = "empty" pullsText } }
  35. if (pullsShown) {
  36. 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)." }
  37. if (pullsNone) { p { id = "nopulls" class = "empty" "No pull request yet." } }
  38. p { id = "mergeerror" class = "message" mergeError }
  39. ol { id = "pulllist"
  40. for (pr of pullsList) {
  41. li {
  42. 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 } } } }
  43. span { class = pr.state pr.state }
  44. span { class = "branches"
  45. if (pr.hasSource) { a { class = "source" href = pr.sourceHref pr.source } }
  46. if (pr.noSource) { span { class = "source muted" "(branch gone)" } }
  47. span { class = "muted" "→" }
  48. if (pr.targetLinked) { a { class = "target" href = pr.targetHref pr.target } }
  49. if (pr.targetMissing) { span { class = "target muted" pr.target " (no such branch)" } }
  50. }
  51. span { class = "muted" pr.author }
  52. time { pr.date }
  53. button { class = pr.mergeClass type = "button" value = pr.sha "Merge" on click(e) { emit mergePull(e.target.value) } }
  54. }
  55. }
  56. }
  57. }
  58. }
  59. }
  60. }
  61. }
  62. // "Merge" (the owner, only when clicked): the face merges and answers with the list read again
  63. on mergePull(sha) {
  64. mergeError = ''
  65. r = emit server gitoriaMergePull(slug, sha)
  66. if (r == null || r.error != null) {
  67. mergeError = r != null ? r.error : 'could not merge'
  68. return null
  69. }
  70. got = r.result
  71. pullsList = r.list
  72. pullsNone = got.noPulls
  73. }
  74. on server gitoriaMergePull(slugOf, sha, session) {
  75. if (session == null || repoAt(slugOf, session) == null) { return { error = 'could not merge' } }
  76. u = userOfSession(session)
  77. if (u == null || !ownsRepo(slugOf, session)) { return { error = 'only the owner can merge a pull request' } }
  78. r = mergePullNow(slugOf, repoAt(slugOf, session).branch, sha, u.name)
  79. if (r.error != null) { return { error = r.error } }
  80. notifyPush(slugOf, false)
  81. // the list again, with its ticket links made here: tickets-helpers.hl reads the environment, which the browser has not
  82. return pullsView(slugOf, repoAt(slugOf, session).branch, true, repoAt(slugOf, session).ticketsProject)
  83. }

Branches

Latest commits

  • 5d2c385agitoria: the sign-in callback keeps the session it finds and signs it in (same cookie, nothing signed out; ident#28); security gate 71+5 failing → 76 passed; deploy.sh runs tests/private.mjs toomre
  • 241ef3f9deploy.sh: rebuild the sshd image before up -d (GO34c)mre
  • 821cdbb1gitoria#34b: styles, create-repo tool, docs, push/ssh gates sign in through the selector, shots scriptmre
  • a81abdc9gitoria#34: org page via function route, member-reachable orgs, selects, reportmre
  • 17f031f0gitoria#34: private repos, organizations, members, move tool, gatemre
  • 71b69343gitoria#23: the sidebar's Repositories link was a 404 after any in-page navigation (static menu re-evaluated publicUrl in the browser); the menu is an instance property now; gate taps it after a tab, folder, filemre
  • 90b4f728gitoria#25: restore the homepage cache and the parsed-blocks cache (they store data under immutable keys, no HTML); the page key, the framework readme key and the textHash key stay removedmre
  • a487248cgitoria#25: remove every cache that hid the page build (page key, Markdown render key, homepage cache, parsed-blocks cache) and the gate that only tested themmre
  • 12f2f4fegitoria: re-vendor Hybriel set-day27b, a startup fault in on Error exits 1mre
  • c21c084egitoria: write the standby service out in full so the boot gate can read the main servicemre
  • e307d69agitoria: say what is per process during the hand-overmre
  • f0cbe6a6gitoria: standby service on port 45014 and a deploy that hands over through it without a gapmre
  • 727cd083gitoria#25: README: vendor notes for Hybriel c1b1010f and the page cachemre
  • 61b72dedgitoria#25: re-vendor Hybriel master c1b1010f (W149 page cache), key the repo Readme page by slug and main commit, extend the readme-cache gatemre
  • 5b0b4b9ereadme-cache gate: use the security gate's ports when no own ports are givenmre
  • bc8f20d9gitoria#25: re-vendor Hybriel c09538bb with the W141 render cache, cache the homepage per commit, add the readme-cache gatemre
  • 9feebbd3Re-vendor Hybriel to ded47c13 (W145: Firefox start script fix)mre
  • 28ed41e5gitoria#24: one sign-in comes from hl:web batch 20, the /session/share workaround is gonemre
  • 3b2669e4gs: drop the unbuildable legacy check, fix pwa fetchmre
  • 2a2fdd77gs: C2 check before cookie experimentsmre