gitoria

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit1997e77d1997e77dgitoria#40: stable PR numbers, refs/pull/N/head, ssh pushes reach the app (merge w40-pr-number)mre1997e77d/components/pulls.hl

5.7 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. import { ensurePulls, syncPulls, withNumbers } from '../lib/pullsync.hl'
  15. host = null
  16. orepo = ''
  17. session = null
  18. slug = slugOfRequest(host, orepo)
  19. repo = repoAt(slug, session)
  20. hasRepo = repo != null
  21. isOwner = repo != null && ownsRepo(slug, session)
  22. mergeError = ''
  23. numbered = repo != null ? ensurePulls(slug) : null
  24. got = repo != null ? pullsNow(slug, repo.branch) : null
  25. pullsShown = got != null && !got.isMessage
  26. pullsMessage = got != null && got.isMessage
  27. pullsText = got != null && got.isMessage ? got.message : ''
  28. pullsNone = got != null && !got.isMessage && got.noPulls
  29. pullsList = got != null && !got.isMessage ? withNumbers(withPullParts(withMerge(got.pulls, isOwner), repo.ticketsProject), slug) : []
  30. pullsDefault = got != null && !got.isMessage ? got.defaultName : ''
  31. __title = pageTitle(siteName, titleSlug(host, orepo, session), 'Pull requests')
  32. View {
  33. repoPage {
  34. if (hasRepo) {
  35. repoPulls { id = "pulls"
  36. if (pullsMessage) { p { id = "pullsmessage" class = "empty" pullsText } }
  37. if (pullsShown) {
  38. 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)." }
  39. if (pullsNone) { p { id = "nopulls" class = "empty" "No pull request yet." } }
  40. p { id = "mergeerror" class = "message" mergeError }
  41. ol { id = "pulllist"
  42. for (pr of pullsList) {
  43. li {
  44. span { class = "subject" span { class = "number" pr.numberText } 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 } } } }
  45. span { class = pr.state pr.state }
  46. span { class = "branches"
  47. if (pr.hasSource) { a { class = "source" href = pr.sourceHref pr.source } }
  48. if (pr.noSource) { span { class = "source muted" "(branch gone)" } }
  49. span { class = "muted" "→" }
  50. if (pr.targetLinked) { a { class = "target" href = pr.targetHref pr.target } }
  51. if (pr.targetMissing) { span { class = "target muted" pr.target " (no such branch)" } }
  52. }
  53. span { class = "muted" pr.author }
  54. time { pr.date }
  55. button { class = pr.mergeClass type = "button" value = pr.sha "Merge" on click(e) { emit mergePull(e.target.value) } }
  56. }
  57. }
  58. }
  59. }
  60. }
  61. }
  62. }
  63. }
  64. // "Merge" (the owner, only when clicked): the face merges and answers with the list read again
  65. on mergePull(sha) {
  66. mergeError = ''
  67. r = emit server gitoriaMergePull(slug, sha)
  68. if (r == null || r.error != null) {
  69. mergeError = r != null ? r.error : 'could not merge'
  70. return null
  71. }
  72. got = r.result
  73. pullsList = r.list
  74. pullsNone = got.noPulls
  75. }
  76. on server gitoriaMergePull(slugOf, sha, session) {
  77. if (session == null || repoAt(slugOf, session) == null) { return { error = 'could not merge' } }
  78. u = userOfSession(session)
  79. if (u == null || !ownsRepo(slugOf, session)) { return { error = 'only the owner can merge a pull request' } }
  80. r = mergePullNow(slugOf, repoAt(slugOf, session).branch, sha, u.name)
  81. if (r.error != null) { return { error = r.error } }
  82. notifyPush(slugOf, false)
  83. // the pull request records follow (merged, mergeCommit: the change is logged until gitoria#43)
  84. syncPulls(slugOf, u.id)
  85. // the list again, with its ticket links made here: tickets-helpers.hl reads the environment, which the browser has not
  86. v = pullsView(slugOf, repoAt(slugOf, session).branch, true, repoAt(slugOf, session).ticketsProject)
  87. return { result = v.result list = withNumbers(v.list, slugOf) }
  88. }
  89. Style {
  90. repoPulls {
  91. display = 'grid'
  92. gap = '1rem'
  93. minWidth = '0'
  94. '> *' {
  95. margin = '0'
  96. }
  97. }
  98. #pulllist {
  99. display = 'grid'
  100. gap = '.4rem'
  101. margin = '0'
  102. padding = '0'
  103. listStyle = 'none'
  104. li {
  105. display = 'flex'
  106. flexWrap = 'wrap'
  107. alignItems = 'center'
  108. gap = '0 .8rem'
  109. margin = '0'
  110. padding = '.1rem 1rem .3rem'
  111. background = 'var(--color-surface)'
  112. borderRadius = 'var(--radius-large)'
  113. overflowWrap = 'anywhere'
  114. }
  115. '.subject' {
  116. flex = '1 1 100%'
  117. '.number' {
  118. marginRight = '.5rem'
  119. color = 'var(--color-text-muted)'
  120. fontWeight = '400'
  121. }
  122. minWidth = '0'
  123. fontWeight = '600'
  124. a {
  125. display = 'inline-block'
  126. paddingBlock = '.65rem'
  127. }
  128. 'a.ticketref' {
  129. minWidth = '2.75rem'
  130. textAlign = 'center'
  131. }
  132. }
  133. '.open' {
  134. fontSize = '.875rem'
  135. color = 'var(--color-accent)'
  136. }
  137. '.nomerge' {
  138. display = 'none'
  139. }
  140. '.merged' {
  141. fontSize = '.875rem'
  142. color = 'var(--color-text-muted)'
  143. }
  144. '.branches' {
  145. display = 'inline-flex'
  146. flexWrap = 'wrap'
  147. alignItems = 'center'
  148. gap = '0 .5rem'
  149. a {
  150. display = 'inline-flex'
  151. alignItems = 'center'
  152. justifyContent = 'center'
  153. minWidth = '2.75rem'
  154. minHeight = '2.75rem'
  155. }
  156. }
  157. 'button.mergepr' {
  158. marginLeft = 'auto'
  159. color = 'var(--color-accent-text)'
  160. background = 'var(--color-accent)'
  161. }
  162. }
  163. }

Branches

Latest commits

  • 1997e77dgitoria#40: stable PR numbers, refs/pull/N/head, ssh pushes reach the app (merge w40-pr-number)mre
  • 9364fb16gitoria#40: ssh pushes call /__git/pushed before and after (ensurePulls, notifyPush, syncPulls); gate over the sshd imagemre
  • fdb9ed28gitoria#41: repo owners can connect an app (merge w41-apps-connect)mre
  • 2ef23df0gitoria#40: the browser gate reads the title without the #Nmre
  • 9af07ecegitoria#41: connect an app to a repo (apps table, connect flow, manual add, allow-list, settings)mre
  • b9137ff0gitoria#40: pull requests are stored with a number, refs/pull/N/head, syncPulls and pullObject; /pulls shows #Nmre
  • 06d622daown image tag gitoria-runtime:debian12 for gitoria and standby (shared tag lost git)mre
  • 20caa33agitoria#37: media queries in the language's @media block (minWidth = '60rem') in list, codebrowser and repomre
  • c4175e6dgitoria: a startup error prints its message before exit 1 (hybriel#247)mre
  • c50d17efKeep function-route not-found style in shared stylesheetmre
  • e42d78d3Preserve ticket state CSS and document function-route style gapmre
  • c6b7154eWIP gitoria#26: move styles into nested component blocksmre
  • 77a2c31cgitoria#31: plain declarations instead of needless let in lib/ and tools/ (103 let removed, 137 kept because reassigned); no other changemre
  • 4b98ab62gitoria: an ident access key (idt_) works as the git password; read key clones only, bad key 401, ident down 503 (ident#27); gate tests/ident-access-gitoria.mjs in deploy.shmre
  • 1185f686gitoria#36: a failed return from tickets shows a note on the settings page and leaves one log line per outcome; no code is exchangedmre
  • 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