Announcing stagit-ng
This is a continuation of the previous blog post of my adventures removing gitea with a static git repository browser. Soon after I had my repositories statically hosted in stagit, I1 started implementing features.
- Add full history. Create a HTML page for every ref, every (unique) tree, extract the blobs for download, and more.
- Speed up stagit by using multiple concurrent workers.
- Implement optimizations for incremental generation, so
git pushto an existing repo will only update the new stuff and take seconds.
At this point my zig repository took about an hour to generate from scratch, which is fine. Then I tried Linux kernel:
As you can see in the graph above, I gave up after about 40 hours. Then an idea came to mind:
Why does the server need to do all the work? Can we push all the work to the client?
Enter stagit-ng
I started writing the next version of stagit, now called
stagit-ng: it downloads the data directly from a bare git
repository and renders it in the browser, thus doing all the work on the client
side. Once I realized I have all the git repository at my fingertips, I started
copying features from cgit and then some.
My favorite feature is the graph mode. Here is a tree mode of Linux v7.0. Open it and click around!
Some more things I am quite proud of:
- Diff between arbitrary commits, e.g. Linux diff between v7.0 and v7.0.1.
- cgit’s summary page, example.
- Nice URLs (no
#). - Markdown rendering with images in the same repository, example in stagit-ng.
- Reasonable caching with progress indicator. To test this, wait until the Linux diff to load, then refresh the page.
- Chromium repository (65GiB bare with many many files, refs and blobs) works nicely.
- The only project dependency is
zig. No Javascript, C or any other out-of-project dependencies. Yes, we parse Markdown and unpack Git refs.
If you want to use it, you will need:
- A web server serving bare repos (“dumb transport”).
- Relatively complex web server configuration (to have nice URLs).
- Put
index.html,stagit-ng.wasm,style.cssandstagit-ng.jsto the web server’s root.
Once I fix some remaining annoyances and write a proper deployment guide, I
will tag stagit-ng v2.0.
Paradigm shift
I purchased the Max Plan in Anthropic and banged stagit-ng in a few evenings
with mostly Claude Fable.
If I were to write this the artisanal way, I estimate this would have taken me a few months. Having a dayjob, family and other volunteering activities, I would not have even started: where’s the fun writing a really good (in my opinion, of course) SPA to preview Git repos in the browser? It’s fun if it takes hours, it’s a grind if it takes months that I will spend on something else.
Secondly, I thought that in 99% of the cases Though Shalt Generate HTML On
Server. This is what I started with with gitea, then stagit. Now I think SPA is
the best for it (I never thought SPA is a good idea to host static content, but
here we are). Ironically, I started out protecting my poor gitea from LLM
farms; in the end, I used an LLM to make the problem go away.
Acknowledgements
Huge thanks to Hiltjo Posthuma for creating stagit.
-
my LLM disclaimer applies. ↩︎