gitoriaLog in with ident

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit68dcb60368dcb603deploy.sh: back up live storage/.sessions/.env before every deploy (newest 5 kept)mre68dcb603/components/pulls.hl

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

Branches

Latest commits

  • 68dcb603deploy.sh: back up live storage/.sessions/.env before every deploy (newest 5 kept)mre
  • e2deed6dgitoria#20: "Add code" only on the Code page of an empty repository, no collapsiblemre
  • 8bb97ffddeploy.sh: never send .git or .gitignore to Byrodinmre
  • fd981932State of 2026-09-27; bin/ no longer tracked (Hybriel commit is in README)mre
  • 4a2d7125initial commitmre