gitoria

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Branchf2-api-bugs26117255|||PR apps API: review comments on files with spaces in their namemref2-api-bugs/reports/P50-REPORT.md

4.2 KB

  1. # P50 — refuse direct pushes to the main branch (gitoria#50)
  2. ## What changed
  3. - **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.
  4. - **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).
  5. - **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.`
  6. - **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.
  7. - README: new short section "Refuse direct pushes to the main branch". `deploy.sh`: `tests/protect-main.mjs` joins GATES.
  8. ## Tests
  9. `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.
  10. - 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.
  11. ## Gates (LC_ALL=C, ports 8720-8739 via GITORIA_GATE_* / *_PORT; 8734 is held by another process, avoided)
  12. 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.
  13. ## DOCS
  14. - Used: HL-PRIMER.md, CODE-ORDER.md, settings.hl's own working shapes (button + `emit server`).
  15. - Gap: COMPONENTS.md/HL-PRIMER have no checkbox/form-switch shape, so I used the existing button toggle of "Make private" (no workaround JS).
  16. - Gap: `'\n'` in a string is not a newline (hybriel#44, known in util.hl `NL`); cost me one test round.
  17. - Gap: `on` is a reserved word and cannot be a parameter name (compile error); not mentioned in the primer.
  18. - 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.
  19. ## Stopped / cleaned
  20. No 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

  • 26117255|||PR apps API: review comments on files with spaces in their namemre
  • b8796cecMerge branch 'f1-broken-json' into mainGitoria
  • 2f2959c5|||PR apps API: broken JSON body gives 400 invalid_json, not 500mre
  • f7c6ca07Merge branch 'ident-chooser-selector' into mainGitoria
  • 691abb8e|||PR tests: find ident identity choice without the removed .choose classmre
  • 16a3530fMerge branch 'heap-revert' into mainGitoria
  • 220a80e0|||PR Remove temporary /__heap route and heap helper; logmre
  • 13f0c342Merge branch 'hl25-records' into mainGitoria
  • a002ecb7|||PR records: HL25 report, heap helper, logmre
  • 2492a55cTemporary keyed /__heap route for the live memory snapshotmre
  • fefaedd2log: tracker PR-only, HL25 startedmre
  • 21aa57calog: parkmre
  • e9f950a8reports: G25c soakmre
  • a7783686log: deploy 9f41ffcmre
  • 9f41ffc1log: W30b mergedmre
  • bef635c1Merge branch 'w30b'mre
  • 15b996a5Org list: keyed rows by @id, newest first, concat instead of hand loopmre
  • c4f6d9e3reports: G25c growth huntmre
  • b88e39f1log: privacy cleanup donemre
  • bfd7826ddocs: neutral example organisation namemre