Files
gotea/README.md
T
lotherk 0e54cb8a02 feat(cgi): switch branches and tags with ?ref
Read the ref query parameter, validate it, pass it to got for tree, blob, raw, and log views, and render a no-JavaScript branch/tag bar. Preserve the ref in repository links and cover dev/main switching and traversal rejection in tests.

Assisted-by: OpenCode:DeepSeek-V4.1-Flash
2026-11-22 14:08:02 +00:00

6.1 KiB

gotea

Gotea is a fork of Gitea with two defining changes:

  • repositories are read and maintained with got (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

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

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

ScriptAlias /cgi-bin/gotea /usr/local/libexec/gotea-cgi
<Directory /usr/local/libexec>
    Options +ExecCGI
    SetHandler cgi-script
</Directory>
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 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/<owner>/<repo>/.

make bb
cgi/pages/install-hook.sh <bare-repo> <pages-root> <allow-file> [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:

GOTEA_PAGES_ROOT=/var/lib/gotea/pages \
GOTEA_BB=third_party/bb/bb \
cgi/pages/publish.sh <bare-repo> owner/repo <commit>

Serve the built output on a separate host:

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; GOT_PATH in the [git] section selects the binary (default got). Non-bare temporary worktrees and the remaining plumbing still use git while the migration proceeds. There is no silent git fallback for the migrated init path.

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/<name>/tree[/path], /repo/<name>/blob/<path>, /repo/<name>/raw/<path>, /repo/<name>/log, /repo/<name>/commit/<rev>.
  • Branch and tag switching uses ?ref=refs/heads/<name> (or refs/tags/<name>) 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.