lotherk 3c6b249810
giteabot backport / giteabot (push) Skipped
release-nightly-snapcraft / build-and-publish (ubuntu-24.04) (push) Canceled after 0s
release-nightly-snapcraft / build-and-publish (ubuntu-24.04-arm) (push) Canceled after 0s
release-nightly / nightly-binary (push) Canceled after 0s
release-nightly / nightly-container (push) Canceled after 0s
feat(got): check branch and tag existence with got
IsBranchExist and IsTagExist now ask got.RefExists instead of git's cat-file
batch. got's exit status is useless here: `got ref -l <unknown>` exits 0 with
no output, and an empty repository reports "HEAD: refs/heads/main" for a branch
that does not exist yet. The wrapper therefore parses the "<name>: <value>"
line and follows symbolic entries with a bounded depth.

IsReferenceExist/IsObjectExist keep the cat-file batch: they answer "is this
object present" for bare and short commit IDs, which got ref cannot, and
`got cat` resolves unknown arguments as paths in HEAD's tree, so it would
report file names as existing objects. That gap is documented, not silent.

Verified: go test ./modules/got ./modules/git (ref_test.go covers both ref
behaviours, the empty repository, and the enclosing-repository escape;
ref_got_test.go covers true/false branches and tags plus a missing got binary).
Full go test ./modules/... ./services/... ./models/... ./routers/... and
make -C cgi check pass.

Assisted-by: splinter:claude-opus-4
2026-11-22 18:02:34 +00:00
2024-07-23 12:07:41 +00:00
2025-06-16 12:03:51 +00:00
2023-01-24 18:52:38 +00:00
2016-11-08 08:42:05 +01:00

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, 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/<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.

S
Description
Gitea fork renamed to gotea, got-centric backend, C99 POSIX CGI frontend (HTML 4.01, CDE/Motif, no JS), bb-based Gotea Pages
Readme MIT
1,020 MiB
0 Stars 3 Watchers 0 Forks
Languages
Go 82.7%
Handlebars 7.1%
TypeScript 5.2%
CSS 1.8%
JavaScript 1.3%
Other 1.8%