penguin/flatgit

flatgit showcase

summary

default branchmaster
default commit2aa1addd3026c867d96e22dc5baeb9b379aded7a

recent commits

commitdateauthorsubject
2aa1add2026-10-15T02:24:53Z斟酌 鵬兄Fixed image overflow
393d1b02026-10-14T05:16:55Z斟酌 鵬兄Allow md links
e9582f82026-10-14T04:13:57Z斟酌 鵬兄Fail fast

files

pathsize
.github/workflows/ci.yml2000
.gitignore87
LICENSE1070
Makefile1584
README.md3302
build.env93
cmd/flatgit/main.go5831
dockerfiles/github.Dockerfile1114
dockerfiles/runtime.Dockerfile977
examples/tinyproxy.json507
go.mod274
go.sum845
internal/buildinfo/buildinfo_gen.go150
internal/config/config.go3941
internal/config/config_test.go482
internal/gitcmd/cancel_other.go97
internal/gitcmd/cancel_unix.go424
internal/gitcmd/gitcmd.go5037
internal/gitcmd/gitcmd_test.go2136
internal/jobqueue/jobqueue.go1565
internal/render/archive.go897
internal/render/manifest.go3168
internal/render/markdown.go2899
internal/render/markdown_test.go5424
internal/render/render.go11223
internal/render/rtree.go3797
internal/render/templates.go5045
internal/server/git_http.go4014
internal/server/server.go3614
internal/webhook/webhook.go4563
resources/flatgit.chart/Chart.yaml139
resources/flatgit.chart/templates/_helpers.tpl580
resources/flatgit.chart/templates/configmap.yaml1124
resources/flatgit.chart/templates/deployment.yaml2592
resources/flatgit.chart/templates/httproutes.yaml833
resources/flatgit.chart/templates/pvc.yaml464
resources/flatgit.chart/templates/secret.yaml220
resources/flatgit.chart/templates/service.yaml393
resources/flatgit.chart/values.yaml1214
resources/robots.txt81

flatgit

A static Git web generator with webhook-driven updates and an optional built-in file server.

The main goal for this projects is to make bots and agents's life easier. Also to relief the stress on them crawling the forge platform interfaces.

Each repository have a manifest.json that lists all available navigation paths.

Demo

Install

via helm

helm show values ./resources/flatgit.chart/ > values.yaml
edit values.yaml
helm upgrade --install -n <NAMESPACE> <RELEASE_NAME> ./resources/flatgit.chart/ -f values.yaml

Philosophy

Git repo in, static browsable site out.

webhook -> git clone/fetch --mirror -> render HTML + JSON -> serve static files

It currently shells out to the real git binary.

Since Git already knows how to deal with packed refs, tags, bare repositories, weird histories, and future compatibility. The main focus is on rendering.

HTML should be served by proper http server if possible. The built-in server is fine but basic.

Current status

Build

make clean build

Config

See examples/tinyproxy.json:

{
  "addr": ":8080",
  "data_dir": "/var/lib/flatgit",
  "webhook": {
    "secret": "change-me"
  },
  "git": {
    "command": "git",
    "clone_timeout": "2m",
    "fetch_timeout": "2m"
  },
  "render": {
    "workers": 2,
    "max_commits": 500
  },
  "repos": [
    {
      "owner": "penguin",
      "name": "test-repo",
      "url": "http://gitea-http.gitea.svc.cluster.local:3000/penguin/test-repo.git",
      "default_branch": "main"
    }
  ]
}

Derived paths:

/var/lib/flatgit/repos/penguin_test-repo.git
/var/lib/flatgit/www/penguin_test-repo

Commands

Render all configured repos:

flatgit render -c examples/flatgit.json

Render one repo:

flatgit render -c examples/flatgit.json -repo penguin_test-repo

Serve an already-rendered web root:

flatgit serve -root /var/lib/flatgit/www -addr :8080

Run the daemon:

flatgit daemon -c examples/flatgit.json

The daemon serves:

/                       static web root
/healthz                health check
/webhook/gitea          Gitea webhook endpoint
/webhook/github         GitHub webhook endpoint

Webhook signature

If webhook.secret is non-empty, the handler accepts either:

The HMAC is SHA-256 over the raw request body.

TODO