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
- 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
- 565cb508log: H25 round 1mre
- 90a0af84log: H25 startedmre
- 87bd53b8mission H25mre
- 71a746cflog: day48 livemre
- bf568e14log: V48 mergedmre
- 09955dedMerge v48: Hybriel set-day48, theme layouts ce4a0bamre
- f2a2b0cevendor: Hybriel set-day48, theme layouts ce4a0bamre
- 5d0834e7log: Apollo model rulemre
- fe8e5bd5log: #25 sample, V48 missionmre
- 8580c5d9log: theme fix from Atlasmre
- 46823d93log: Apollo budget correctionmre
- f6d32341log: Apollo on budget and #25 nextmre
- d7184f53log: batch live, #25 evidencemre
- 5e25e816log: W61 mergedmre
- aafe330dTidy: drop evidence JSON (kept in scratch), collapse blank linesmre
- aca1fda1Merge W61: theme from layouts 17e0f03, Views refer to Style rules (gitoria#37 #27)mre
- 03cb650blog: W61 theme decisionmre
- 248bce85Report final style gates, CSS mappings and 136 whole-image comparisonsmre
- 153c344bRestore organization metadata exposed by the whole-image comparisonmre
- 917a1465Update status gate assertions for the referenced state rulemre