gitoria
All repositories: gitoria
6.8 KB
// components/pulls.hl — THE PULL REQUESTS of a repo (gitoria#11, gitoria#16): `/pulls` on <slug>.<domain>, its// own route. The repo head is rendered on the server from the request's host. The list comes from git (the// commits whose message starts with |||PR) on the SERVER too// (lib/pulls.hl pullsNow — hl:proc run() waits, hybriel#80): it is in the first HTML and in every hl:web navigation.parent './repo.hl'import { siteName } from '../project.hl'import { slugOfRequest } from '../lib/orgs.hl'import { userOfSession } from '../lib/users.hl'import { titleSlug, repoAt, ownsRepo } from '../lib/repos.hl'import { pageTitle } from '../lib/repos-helpers.hl'import { pullsNow, mergePullNow, withMerge, pullsView } from '../lib/pulls.hl'import { withPullParts } from '../lib/tickets-helpers.hl'import { notifyPush } from '../lib/tickets.hl'import { ensurePulls, withNumbers } from '../lib/pullsync.hl'import { syncAndRaise } from '../lib/events.hl'import { withStatuses } from '../lib/statuses.hl'host = nullorepo = ''session = nullslug = slugOfRequest(host, orepo)repo = repoAt(slug, session)hasRepo = repo != nullisOwner = repo != null && ownsRepo(slug, session)mergeError = ''numbered = repo != null ? ensurePulls(slug) : nullgot = repo != null ? pullsNow(slug, repo.branch) : nullpullsShown = got != null && !got.isMessagepullsMessage = got != null && got.isMessagepullsText = got != null && got.isMessage ? got.message : ''pullsNone = got != null && !got.isMessage && got.noPullspullsList = got != null && !got.isMessage ? withNumbers(withStatuses(withPullParts(withMerge(got.pulls, isOwner), repo.ticketsProject), slug), slug) : []pullsDefault = got != null && !got.isMessage ? got.defaultName : ''__title = pageTitle(siteName, titleSlug(host, orepo, session), 'Pull requests')View {repoPage {if (hasRepo) {repoPulls { id = "pulls"if (pullsMessage) { p { id = "pullsmessage" class = "empty" pullsText } }if (pullsShown) {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)." }if (pullsNone) { p { id = "nopulls" class = "empty" "No pull request yet." } }p { id = "mergeerror" class = "message" mergeError }ol { id = "pulllist"for (pr of pullsList) {li {span { class = "subject" span { class = "number" pr.numberText } for (pt of pr.parts) { if (pt.isText) { a { href = pr.pageHref pt.text } } if (pt.isLink) { a { class = "ticketref" href = pt.href pt.text } } } }span { class = pr.state pr.state }span { class = "branches"if (pr.hasSource) { a { class = "source" href = pr.sourceHref pr.source } }if (pr.noSource) { span { class = "source muted" "(branch gone)" } }span { class = "muted" "→" }if (pr.targetLinked) { a { class = "target" href = pr.targetHref pr.target } }if (pr.targetMissing) { span { class = "target muted" pr.target " (no such branch)" } }}span { class = "statuses"for (st of pr.statuses) {span { class = st.clsspan { class = "state" st.state }span { class = "label" st.label }span { class = "muted" st.title }}}}span { class = "muted" pr.author }time { pr.date }span { class = "blocked" pr.blockText }button { class = pr.mergeClass type = "button" value = pr.sha "Merge" on click(e) { emit mergePull(e.target.value) } }}}}}}}}}// "Merge" (the owner, only when clicked): the face merges and answers with the list read againon mergePull(sha) {mergeError = ''r = emit server gitoriaMergePull(slug, sha)if (r == null || r.error != null) {mergeError = r != null ? r.error : 'could not merge'return null}got = r.resultpullsList = r.listpullsNone = got.noPulls}on server gitoriaMergePull(slugOf, sha, session) {if (session == null || repoAt(slugOf, session) == null) { return { error = 'could not merge' } }u = userOfSession(session)if (u == null || !ownsRepo(slugOf, session)) { return { error = 'only the owner can merge a pull request' } }r = mergePullNow(slugOf, repoAt(slugOf, session).branch, sha, u.name)if (r.error != null) { return { error = r.error } }notifyPush(slugOf, false)// the pull request records follow (merged, mergeCommit) and the connected apps hear of it (lib/events.hl)syncAndRaise(slugOf, u.id)// the list again, with its ticket links made here: tickets-helpers.hl reads the environment, which the browser has notv = pullsView(slugOf, repoAt(slugOf, session).branch, true, repoAt(slugOf, session).ticketsProject)return { result = v.result list = withNumbers(v.list, slugOf) }}Style {repoPulls {display = 'grid'gap = '1rem'minWidth = '0''> *' {margin = '0'}}#pulllist {display = 'grid'gap = '.4rem'margin = '0'padding = '0'listStyle = 'none'li {display = 'flex'flexWrap = 'wrap'alignItems = 'center'gap = '0 .8rem'margin = '0'padding = '.1rem 1rem .3rem'background = 'var(--color-surface)'borderRadius = 'var(--radius-large)'overflowWrap = 'anywhere'}'.subject' {flex = '1 1 100%''.number' {marginRight = '.5rem'color = 'var(--color-text-muted)'fontWeight = '400'}minWidth = '0'fontWeight = '600'a {display = 'inline-block'paddingBlock = '.65rem'}'a.ticketref' {minWidth = '2.75rem'textAlign = 'center'}}'.open' {fontSize = '.875rem'color = 'var(--color-accent)'}'.nomerge' {display = 'none'}'.blocked' {fontSize = '.875rem'color = 'var(--color-text-muted)'}'.statuses' {display = 'flex'flex = '1 1 100%'flexWrap = 'wrap'gap = '.25rem .5rem''.badge' {display = 'inline-flex'flexWrap = 'wrap'alignItems = 'center'gap = '0 .4rem'padding = '.1rem .6rem'fontSize = '.8125rem'background = 'var(--color-background-sunken)'borderRadius = 'var(--radius-large)''.state' {fontWeight = '600'}}'.success' {color = 'var(--color-success)'}'.failure' {color = 'var(--color-danger)'}'.error' {color = 'var(--color-text-strong)'fontStyle = 'italic'}}'.merged' {fontSize = '.875rem'color = 'var(--color-text-muted)'}'.branches' {display = 'inline-flex'flexWrap = 'wrap'alignItems = 'center'gap = '0 .5rem'a {display = 'inline-flex'alignItems = 'center'justifyContent = 'center'minWidth = '2.75rem'minHeight = '2.75rem'}}'button.mergepr' {marginLeft = 'auto'color = 'var(--color-accent-text)'background = 'var(--color-accent)'}}}
Branches
- f1-broken-json
- f2-api-bugs
- gp-gate-ports
- heap-revert
- hl25-records
- ident-chooser-selector
- mainmain branch
- p51-public-pr-reads
- records-1112
- s25-no-session-on-login-error
- v59
- w52-person-approval
- w52b-approval-followup
- w52c-header-phone
- w53-pulls-speed-pr
- w54-repo-rename-pr
- w55-rename-org
- w56-owner-members
- w62-pr-close
- w63-force-push
- w64-org-slash
Latest commits
- 2175e48clogmre
- 40eb3ca1gitoria#38: review package, logmre
- 06a5a50egitoria#38: deploy b8252ca, logmre
- b8252ca0gitoria#46: W46b report, logmre
- 50093aafgitoria#46: statuses keyed by app + context (merge w46b-keyed)mre
- dd0267edgitoria#46: fix a label in the keyed gatemre
- b1dcb580gitoria#46: statuses keyed by app + context, required = app + context, old rows still readmre
- 2287363egitoria#47: W47 report, logmre
- 9f502db1gitoria#46: W46b briefmre
- 9678a8f3gitoria#46: contract v1.4, statuses keyed by app + contextmre
- bdcbbaa9gitoria#47: rate limits, status read route, statuses + required on the pull (merge w47-limits)mre
- 772c401fgitoria#45: W45 report, logmre
- b6b793afgitoria#45: PR page with reviews, threads, conversation, Review again (merge w45-pr-page)mre
- fb9e7554gitoria#45: browser gate: a /pulls title links to the PR pagemre
- f7198131gitoria#45: tests/pr-page.mjs gatemre
- 483141d0gitoria#45: Settings shows the Apps heading only to the ownermre
- e2eff8f6gitoria#45: the PR page /pulls/N with reviews, threads, verdicts, conversation, comment, reply, resolve and Review againmre
- 7a602839gitoria#45: raiseEvent can send to one app only; people's comments, replies and resolving in reviews.hlmre
- 5de7f578gitoria#47: rate limits per app (429, Retry-After), status read route, statuses and required on the pull, one JSON check for every write routemre
- 19edc1f5gitoria#44: contract v1.3.1, what outdated meansmre