gitoria
All repositories: gitoria
1.6 KB
// Person approvals, keyed by record id and scoped to repository, PR number and head.// Every write to approvals.db is here; callers re-check the real session's push rights.import { MPackDB } from 'hl:mpackdb'import { now, timestamp } from 'hl:time'import { storageDir, countOfList } from './util.hl'import { nameOfUser } from './users.hl'static approvalsTable = new MPackDB(file = storageDir + '/approvals.db', primaryKey = '@id', indexes = ['rid'])static approvalsOf = (String rid, Number number) => {out = []rows = approvalsTable.find('rid', rid)if (countOfList(rows) > 0) { for (r of rows) { if (r.number == number) { out.push(r) } } }return out}static approvalsJson = (String rid, Number number, String head) => {out = []for (r of approvalsOf(rid, number)) {current = r.head == headout.push({ user = { id = r.userId name = nameOfUser(r.userId) } head = r.head created = timestamp(r.created) current = current })}return out}static hasApproval = (String rid, Number number, String userId, String head) => {for (r of approvalsOf(rid, number)) { if (r.userId == userId && r.head == head) { return true } }return false}static setApproval = (String rid, Number number, String userId, String head, Boolean wanted) => {if (!wanted) {for (r of approvalsOf(rid, number)) { if (r.userId == userId && r.head == head) { approvalsTable.delete(r.id) } }return { ok = true }}if (hasApproval(rid, number, userId, head)) { return { ok = true } }id = approvalsTable.put({ rid = rid number = number userId = userId head = head created = now() })return id == null ? { error = 'could not store the approval' } : { ok = true }}
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
- 3ae94b86Record browser failures and verify owned tab cleanupmre
- 54eec687Gate person approvals and merge alternativesmre
- 12b08829Add person approvals for pull request headsmre
- 55c84779Merge branch 'gp-gate-ports' into mainGitoria
- 57af42bbREADME: point to deploy.sh for the port listmre
- d63375d2README: gate commands with explicit portsmre
- feeaa701|||PR gates: explicit ports only, deploy.sh passes themmre
- 6cc1f943Merge branch 'records-1112' into mainGitoria
- 9448c438|||PR records: LOG, missions and reports since 11-09mre
- 6dc08a8eMerge branch 'p51-public-pr-reads' into mainGitoria
- 7b88cfe0Type publicReaderOfRequest parameters (L10)Gitoria
- 2a4b3dc1|||PR Anonymous reads of public repos' pulls and statusesmre
- 21b2c141Merge branch 's25-no-session-on-login-error' into mainGitoria
- 698458e2|||PR No session for cookieless login errors: READMEmre
- cce7b785|||PR No session for cookieless login errorsmre
- 678d6303Merge branch 'v59' into mainGitoria
- 5803cf4f|||PR vendor: Hybriel set-day59 and GC budget 32 MiBmre
- 9eff6627Merge branch 'f2-api-bugs' into mainGitoria
- 26117255|||PR apps API: review comments on files with spaces in their namemre
- b8796cecMerge branch 'f1-broken-json' into mainGitoria