gitoria
All repositories: gitoria
7.7 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, repoBySlug, mayPush } from '../lib/repos.hl'import { pageTitle } from '../lib/repos-helpers.hl'import { pullsNow, withMerge, pullsView } from '../lib/pulls.hl'import { mergeAndAnnounce } from '../lib/pullmerge.hl'import { withPullParts } from '../lib/tickets-helpers.hl'import { ensurePulls, withNumbers } from '../lib/pullsync.hl'import { withStatuses } from '../lib/statuses.hl'host = nullorepo = ''session = nullslug = slugOfRequest(host, orepo)repo = repoAt(slug, session)hasRepo = repo != nullmayMerge = repo != null && userOfSession(session) != null && mayPush(userOfSession(session).id, repoBySlug(slug))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, mayMerge), 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" mergeError }ol { id = "pulllist"for (pr of pullsList) {li {span { Style.spanSubject span { Style.spanNumber 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 } } } }// Runtime class selection has no Style-rule expression form.span { class = pr.state pr.state }span { Style.spanBranchesif (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 { Style.spanStatusesfor (st of pr.statuses) {// Runtime class selection has no Style-rule expression form.span { class = st.clsspan { Style.spanPullStatusState st.state }span { class = "label" st.label }span { class = "muted" st.title }}}}span { class = "muted" pr.author }time { pr.date }span { Style.spanBlocked pr.blockText }// Runtime class selection has no Style-rule expression form.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 || !mayPush(u.id, repoBySlug(slugOf))) { return { error = 'only the owner and the members of this repository can merge a pull request' } }// the merge, the pull request records (merged, mergeCommit) and the connected apps' event: lib/pullmerge.hl, the same as the API'sr = mergeAndAnnounce(repoBySlug(slugOf), sha, u, '')if (r.error != null) { return { error = r.error } }// 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'// Direct-child and sibling combinators have no bare language form.'> *' {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'}// Runtime and theme class predicates have no bare selector form.'.open' {fontSize = '.875rem'color = 'var(--color-accent)'}// Runtime and theme class predicates have no bare selector form.'.nomerge' {display = 'none'}// Runtime and theme class predicates have no bare selector form.'.merged' {fontSize = '.875rem'color = 'var(--color-text-muted)'}// Runtime and theme class predicates have no bare selector form.'button.mergepr' {marginLeft = 'auto'color = 'var(--color-accent-text)'background = 'var(--color-accent)'}}spanNumber {marginRight = '.5rem'color = 'var(--color-text-muted)'fontWeight = '400'}spanPullStatusState {fontWeight = '600'}spanSubject {flex = '1 1 100%'minWidth = '0'fontWeight = '600'a {display = 'inline-block'paddingBlock = '.65rem'}// Runtime and theme class predicates have no bare selector form.'a.ticketref' {minWidth = '2.75rem'textAlign = 'center'}}spanBranches {display = 'inline-flex'flexWrap = 'wrap'alignItems = 'center'gap = '0 .5rem'a {display = 'inline-flex'alignItems = 'center'justifyContent = 'center'minWidth = '2.75rem'minHeight = '2.75rem'}}spanStatuses {display = 'flex'flex = '1 1 100%'flexWrap = 'wrap'gap = '.25rem .5rem'// Runtime and theme class predicates have no bare selector form.'.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)'}// Runtime and theme class predicates have no bare selector form.'.success' {color = 'var(--color-success)'}// Runtime and theme class predicates have no bare selector form.'.failure' {color = 'var(--color-danger)'}// Runtime and theme class predicates have no bare selector form.'.error' {color = 'var(--color-text-strong)'fontStyle = 'italic'}}spanBlocked {fontSize = '.875rem'color = 'var(--color-text-muted)'}#mergeerror {margin = '0'color = 'var(--color-danger)'empty { display = 'none' }}}
Branches
Latest commits
- 220a80e0|||PR Remove temporary /__heap route and heap helper; logmre
- 13f0c342Merge branch 'hl25-records' into mainGitoria
- a002ecb7|||PR records: HL25 report, heap helper, logmre
- 2492a55cTemporary keyed /__heap route for the live memory snapshotmre
- fefaedd2log: tracker PR-only, HL25 startedmre
- 21aa57calog: parkmre
- e9f950a8reports: G25c soakmre
- a7783686log: deploy 9f41ffcmre
- 9f41ffc1log: W30b mergedmre
- bef635c1Merge branch 'w30b'mre
- 15b996a5Org list: keyed rows by @id, newest first, concat instead of hand loopmre
- c4f6d9e3reports: G25c growth huntmre
- b88e39f1log: privacy cleanup donemre
- bfd7826ddocs: neutral example organisation namemre
- 01b71c2edocs: neutral wording in missions, reports and logmre
- 3eeea733log: 2026-11-09 PR flow plan and membersmre
- e7c2ff1fdocs: neutral name for the apps-api reviewmre
- 120b7abdlog: step 3 queuedmre
- 358474bflog: P50 livemre
- 477d7bdcMerge branch 'p50'mre