gitoria
All repositories: gitoria
5.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, 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'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(withPullParts(withMerge(got.pulls, isOwner), repo.ticketsProject), 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.href 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 = "muted" pr.author }time { pr.date }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'}'.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
- 49533a50gitoria#43: signed events to connected apps (merge w43-events)mre
- 1a1e87d5gitoria#43: the sender never writes the apps row; Settings shows the newest deliverymre
- cd442066gitoria#43: app-auth unit test reads the apps table from its new filemre
- 5dccbe38gitoria#43: in-flight rows are left alone by the other process; gate in deploy.sh; READMEmre
- 8c8805f3merge main (gitoria#42), delivery log and redelivery routes, sweep fixmre
- 5a996ea8gitoria#42: short-lived app tokens, read-only git fetch with them (merge w42-app-token)mre
- afdb0cbfgitoria#43: rename the moved helper (name clash in the browser build)mre
- 15e01e94gitoria#43: tests/events.mjs and its probemre
- 77829b73gitoria#43: signed events to connected apps (deliveries table, sender timer, pull_request events, ping)mre
- b5d696fegitoria#42: app tokens (gat_, one hour), appOfRequest, app token as the git read passwordmre
- 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