# gotea Gotea is a fork of [Gitea](https://github.com/go-gitea/gitea) with two defining changes: - repositories are read and maintained with [got](https://got.gameoftrees.org/) (Game of Trees) instead of the `git` binary, and - an HTML 4.01 frontend written in C99/POSIX serves repositories over CGI, with no JavaScript and a CDE/Motif look. The fork is based on Gitea v28.4.0. Upstream history and licensing are retained. ## Status This tree is at the bootstrap milestone: | Layer | State | | --- | --- | | Go backend | Imported and building as `gotea` (module `gotea.dev`). Bare repository creation uses `got` via `modules/got`; most other operations still use `git`. | | Legacy frontend | `cgi/gotea-cgi`: read-only browser over `got`, HTML 4.01 Transitional, no JavaScript, CDE palette. | | Pages | Prototype: a `pages` branch is checked out with got, built with vendored `bb`, and served on a separate host. | | Auth and writes | Not yet implemented in the CGI frontend. | ## Build ```sh make gotea # Go backend binary go test ./modules/got # got wrapper and bare-init tests make build # full Gitea build; needs pnpm and Node make -C cgi # C99 CGI binary make -C cgi check # CGI + pages tests (git is used only for fixtures) make bb # vendored bb static site generator ``` ## Run the CGI ```sh GOTEA_REPO_ROOT=/var/lib/gotea/data/gitea-repositories \ GOT_BIN=/usr/bin/got \ SCRIPT_NAME=/cgi-bin/gotea \ REQUEST_METHOD=GET PATH_INFO=/ \ ./cgi/gotea-cgi ``` Point `GOTEA_REPO_ROOT` at Gotea's `data/gitea-repositories`. Both flat (`repo.git`) and owner-scoped (`owner/repo.git`) layouts are supported. ### Deploy with Apache ```apache ScriptAlias /cgi-bin/gotea /usr/local/libexec/gotea-cgi Options +ExecCGI SetHandler cgi-script SetEnv GOTEA_REPO_ROOT /var/lib/gotea/data/gitea-repositories SetEnv GOT_BIN /usr/bin/got ``` For nginx, run the CGI through `fcgiwrap`; the binary does not need a daemon. **Access control:** `gotea-cgi` is read-only and does not authenticate. It serves every repository under `GOTEA_REPO_ROOT` to anyone who can reach it. Use it only for public repositories, or put it behind web-server authentication, until the auth layer lands. ## CGI configuration | Variable | Default | Meaning | | --- | --- | --- | | `GOTEA_REPO_ROOT` | `./repositories` | Directory with bare Git-format repositories | | `GOT_BIN` | `got` | got binary | | `GOTEA_PALETTE` | built-in CDE palette | `key=value` colour file | | `GOTEA_DEBUG` | unset | Show `got` stderr on error pages | | `SCRIPT_NAME` | `/cgi-bin/gotea` | CGI mount point, set by the web server | | `GOTEA_PAGES_HOST` | unset | Serve pages only when `HTTP_HOST` matches this | | `GOTEA_PAGES_ROOT` | unset | Root of the built project sites | | `GOTEA_PAGES_ALLOW` | unset | File listing `owner/repo` sites that may be served | Palette keys: `base`, `light`, `white`, `dark`, `shadow`, `text`, `link`, `visited`, `title_bg`, `title_fg`, `code_bg`, `code_fg`. Values must be `#rgb` or `#rrggbb`. See `cgi/palettes/cde-default.palette`. Real CDE `.dp` palettes (eight colour slots) are also accepted; see `cgi/palettes/cde-default.dp`. ## Pages A `pages` branch is a [bb](https://git.hiddenbox.org/lotherk/bb) project. On push, the post-receive hook checks the branch out with `got`, runs `bb build`, and atomically swaps the built `dist/` into `GOTEA_PAGES_ROOT///`. ```sh make bb cgi/pages/install-hook.sh [bb] [branch] ``` The installer adds `owner/repo` to the allowlist and writes `hooks/gotea-pages.env`; Gitea's delegate hook runs `hooks/post-receive.d/*`. Manual publish: ```sh GOTEA_PAGES_ROOT=/var/lib/gotea/pages \ GOTEA_BB=third_party/bb/bb \ cgi/pages/publish.sh owner/repo ``` Serve the built output on a **separate host**: ```sh GOTEA_PAGES_HOST=pages.example.com \ GOTEA_PAGES_ROOT=/var/lib/gotea/pages \ GOTEA_PAGES_ALLOW=/etc/gotea/pages.allow \ ./cgi/gotea-cgi ``` `GOTEA_PAGES_HOST` must match `HTTP_HOST` exactly. Without `HTTP_HOST`, the CGI falls back to `SERVER_NAME:SERVER_PORT` (ports 80 and 443 are omitted). Other hosts get 404. Only allowlisted repositories are served, and the pages host never exposes the main UI. Keep private repositories out of the allowlist: the publisher has no visibility check. Optional publisher settings are `GOTEA_PAGES_BRANCH` (default `pages`), `GOTEA_PAGES_THEME`, `GOTEA_PAGES_SUBDIR`, and `GOTEA_PAGES_STRICT=1` to fail the push when publishing fails. bb is vendored under `third_party/bb` (MIT, upstream commit in `third_party/bb/NOTICE`), so a checkout builds without an installed bb. `make bb-check` runs bb's own suite; it currently reports 20 upstream theme contrast failures (925/945 pass), which do not affect the build path. ## Backend got migration Bare repositories are created with `got init` through `modules/got`, and `IsEmpty`, `GetDefaultBranch`, `SetDefaultBranch`, `GetBranchCommitID`, `GetBranchNames`, plus the branch/tag existence checks (`IsBranchExist`, `IsTagExist` via `RefExists`) use got. Unborn branches write HEAD atomically because `got ref -s` requires the target branch to exist. `GOT_PATH` in the `[git]` section selects the binary (default `got`). Non-bare temporary worktrees and pushing still use git while the migration proceeds. There is no silent git fallback for the migrated paths. `IsReferenceExist` and `IsObjectExist` stay on git's cat-file batch: they answer "is this object present", including bare and abbreviated commit IDs, which `got ref` cannot express. `got cat` is not a replacement either — it resolves unknown arguments as paths inside HEAD's tree, so a file name would answer as an existing object. ## Design notes - HTML 4.01 Transitional, CSS1, table layout, no JavaScript, no external assets. - CDE/Motif cues: grey panels, bevelled borders, navy title bars, Front Panel sidebar. - The CGI is read-only; `got` is its only repository reader, with no shell invocation and no `git` fallback. - Routes: `/`, `/repo//tree[/path]`, `/repo//blob/`, `/repo//raw/`, `/repo//log`, `/repo//commit/`. - Branch and tag switching uses `?ref=refs/heads/` (or `refs/tags/`) on tree, blob, raw, and log pages; no JavaScript is involved. ## Why the backend is not rewritten in C Gitea's value is its forge backend: authentication, permissions, issues, pull requests, API, and migrations. Rewriting that up front would discard working, security-sensitive code and delay the interface the fork actually needs. The old-browser interface is therefore a C99 CGI presentation tier over the same repositories, and it can take over more of the UI incrementally. ## License MIT. Upstream copyright and license notices are retained; see `LICENSE`.