From 56516707f9fd4ff880bdf8e9cadfc4b2ea800d14 Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Sun, 14 Sep 2025 16:39:13 -0700 Subject: [PATCH] Add `README.md` renderer to `post-update` hook --- README.md | 3 +++ srv/git/git-shell-commands/init | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6f59626..f81798e 100644 --- a/README.md +++ b/README.md @@ -16,12 +16,15 @@ sudo apt install git gitweb highlight ufw fcgiwrap See [Caddy: Install](https://caddyserver.com/docs/install) for directions on installing `caddy`. +See [Comrak](https://github.com/kivikakk/comrak) for installing `comrak`. + Explanation: - `git`, `gitweb` are naturally required. - `highlight` for code syntax highlighting on the web view. - `ufw` for setting up firewall rules (can substitute with whatever you like). - `fcgiwrap` to call the `gitweb` and `git-http-backend` FastCGI scripts. - `caddy` for the web server to serve the web view and repos over HTTPS. +- `comrak` for rendering `README.md` as close to GitHub as possible. 2. Clone this repo somewhere on the server. diff --git a/srv/git/git-shell-commands/init b/srv/git/git-shell-commands/init index 7ed11ea..3aee44a 100644 --- a/srv/git/git-shell-commands/init +++ b/srv/git/git-shell-commands/init @@ -44,13 +44,15 @@ git init --bare --quiet # Commented out to simplify administration (not dealing with cron jobs to remove repos) # git maintenance start -# Create post-update hook for dumb HTTP transport and general maintenance +# Create post-update hook for dumb HTTP transport, generating README for summary view, +# and general maintenance. # See https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols#_dumb_http) # See https://git-scm.com/docs/git-maintenance # See https://git-scm.com/book/en/v2/Git-Internals-Maintenance-and-Data-Recovery cat > "$path/hooks/post-update" << EOL #!/bin/sh git update-server-info +git cat-file blob HEAD:README.md | comrak > $GIT_DIR/README.html git maintenance run EOL chmod a+x "$path/hooks/post-update" -- 2.47.3