gitoria
All repositories: gitoria
4.2 KB
# P50 — refuse direct pushes to the main branch (gitoria#50)## What changed- **Setting** (default OFF, existing repos unchanged): owner button in Settings > Visibility, `components/settings.hl:45-48,92-93,234-248` (state text + "Refuse direct pushes to the main branch" / "Allow direct pushes"). Stored as field `protect` of the repo record: `lib/repos.hl:268-294` (`syncProtect`, `isProtectedMain`, `setProtectMain`; owner only, others get `only the owner can change this`), `lib/repos-helpers.hl` `withChange` keeps the field. The repo JSON (`rowOf`, /api/repos) is NOT changed, so docs/apps-api.md is untouched.- **Enforcement in the server**: new `docker/sshd/hooks/pre-receive`. It reads `<repo>.git/gitoria-protect` (the branch name = the repo's main-branch/PR-target setting, else `main`; no file = off; written by the setting and rewritten by "Make main", `lib/repos.hl:258-266`). HTTPS: `lib/transport.hl:45-53` passes `-c core.hooksPath=<app>/docker/sshd/hooks` to receive-pack (`lib/git.hl:17` `hooksDir`). SSH: `docker/sshd/gitoria-shell:36-37` sets `core.hooksPath=/usr/local/share/gitoria-hooks`; `docker/sshd/Dockerfile` copies the hook there (the sshd image must be rebuilt on deploy).- **Message** (one line, git shows it as `remote: gitoria: ...`): `direct pushes to 'main' are refused in this repository. Push a branch with a '|||PR ' commit and merge it on the /pulls page.`- **Decision on scope**: refused = update (also force) and delete of the protected branch. Allowed = all other branches, all tags, and the creation of the branch (old id all zeros, so the first push to an empty repo works). Merge button / merge API use `update-ref`, not a push, and work.- README: new short section "Refuse direct pushes to the main branch". `deploy.sh`: `tests/protect-main.mjs` joins GATES.## Tests`tests/protect-main.mjs`: 41 passed, 0 failed (ports 8731 app, 8733 sshd, 8735 ident). Real ident login, real git, the real sshd container. Covers: OFF: push + update over HTTPS and SSH works, no marker; member, stranger and signed-out user cannot switch it on, and a member cannot switch it off; the owner switches it on (settings page shows the state); ON: update, force push and delete of main refused over HTTPS and SSH with the message and main unmoved; branch and tag pushes (HTTPS and SSH) work; two `|||PR` branches become PRs and merge via API (`POST /api/pulls/N/merge`) and the Merge-button face (`gitoriaMergePull`); empty repo: switched on, first push creating main works, second refused; after "Make main" to `feat2` the marker names `feat2`, feat2 is refused and main is free; OFF again works. It fails on a broken hook: during development an earlier run with the marker mis-written (literal `\n`, hybriel#44) made all 6 refusal checks FAIL.- Note on "403": the setting is changed by the page's server face (like Make private), which answers `{error}` with HTTP 200 for a non-owner; there is no REST route (no API change wanted). The test asserts the error and that nothing was stored.## Gates (LC_ALL=C, ports 8720-8739 via GITORIA_GATE_* / *_PORT; 8734 is held by another process, avoided)check-theme 86 files 0 problems; browser 293/0; create-api 47/0; signin-return 3/0; security 82/0; private 158/0; ident-access-gitoria 30/0; apps 95/0; pull-numbers 48/0; pull-ssh 20/0; app-token 42/0; reviews 98/0; events 52/0; pr-page 61/0; status 61/0; limits 53/0; status-keyed 13/0; member-merge 82/0; protect-main 41/0.## DOCS- Used: HL-PRIMER.md, CODE-ORDER.md, settings.hl's own working shapes (button + `emit server`).- Gap: COMPONENTS.md/HL-PRIMER have no checkbox/form-switch shape, so I used the existing button toggle of "Make private" (no workaround JS).- Gap: `'\n'` in a string is not a newline (hybriel#44, known in util.hl `NL`); cost me one test round.- Gap: `on` is a reserved word and cannot be a parameter name (compile error); not mentioned in the primer.- Not tried in his Chrome (no UI layout change beyond one more paragraph + button in the existing Visibility section, reusing the `#togglepriv` style); screenshot proof left to the lead.## Stopped / cleanedNo process of mine left (gate servers, docker `gitoria-sshd-pmgate` removed; scratch store deleted; no Chrome of mine). Local `bin` symlink removed, not committed. Nothing pushed or deployed.
Branches
Latest commits
- fe209ffeMerge branch 'w56-owner-members' into mainGitoria
- fa0754c8|||PR repository owner transfer and members API (#55)mre
- 8862e537Merge branch 'w55-rename-org' into mainGitoria
- 014d2b7fOne immutable readers snapshot per move for the left-organization event (#53)mre
- 1859d506Decide who hears a repo left its organization by its readers before the move (#53)mre
- 499f25f2Review fixes for the Settings organization move (#53)mre
- ed3b922b|||PR move a repository into an organization in Settings (#53)mre
- 74ec2af8Merge branch 'w54-repo-rename-pr' into mainGitoria
- 9f7ce8d8Preserve rename compatibility and live page titlesmre
- c3d95b6e|||PR separate names and addresses, rename repositories in Settings (#53)mre
- ce08920dMerge branch 'w52c-header-phone' into mainGitoria
- 0bab9e46|||PR header: ident status wraps on phones instead of clippingmre
- e7af3eceMerge branch 'w52b-approval-followup' into mainGitoria
- c01e66c6|||PR approvals follow-up: live Merge after status writes, helpers (#52)mre
- 841da497Merge branch 'w53-pulls-speed-pr' into mainGitoria
- 80307ae2|||PR pulls page cache: live PR numbers, complete scans onlymre
- 69141f65|||PR pulls page: cache the git part per repo by branch tipsmre
- 155861f6Merge branch 'w52-person-approval' into mainGitoria
- b5435de8|||PR person approvals: second Kunibert round (#52)mre
- 3a8b2fb8|||PR person approvals: Kunibert review fixes (#52)mre