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
- 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
- 00efc06fP50 reportmre
- eefa2dbcRepo setting: refuse direct pushes to the main branch (pre-receive over HTTPS and ssh)mre
- 25309981log: STOP and paused workers 2026-11-08mre
- 5286803alog: worker briefs and reports of 2026-11-08mre
- 85c86605log: 2026-11-08 Arachne on list shapemre
- cb634512log: 2026-11-08 keyed lists livemre
- 07c98d4aLists: keyed rows with @id, remove(id) and one whole-list assignment instead of hand-rebuilt loopsmre
- 0db0d81elog: 2026-11-08 day52 live, W30 startedmre
- b05f6d92tests/status: the gate's 3 s app token expired during the restart; it lives 60 s like status-keyedmre
- 1e8f4f0avendor: Hybriel set-day52 (fault-path leak fix #335, keyed rows #331)mre
- f5f0fb7blog: 2026-11-08 day50/#29 live, H25 correction, V52 startedmre
- dc77fb95main: offline note from __hlOnline, tick removed (#29)mre
- 37a86d93tests/reviews: seeded fake hook's DNS failures are not server errors (flaky gate)mre
- 07ab845bvendor: Hybriel set-day50 (run() leak fix #335)mre
- 71b2fa4blog: hybriel#335mre
- bd94cc7elog: #25 cause found (run() leak)mre
- 565cb508log: H25 round 1mre
- 90a0af84log: H25 startedmre
- 87bd53b8mission H25mre
- 71a746cflog: day48 livemre