the static git browser that builds this site
git clone https://git.lucas.co/gitsite.git
build.sh (1.4K)
1 #!/bin/sh
2 # Build git.lucas.co: sync repo mirrors, generate HTML, lay down dumb-http clones.
3 # Output goes to ~/.cache/gitsite/out (kept out of Dropbox on purpose).
4 set -e
5
6 BASE=$(dirname "$(readlink -f "$0")")
7 CACHE="$HOME/.cache/gitsite"
8 mkdir -p "$CACHE/mirrors"
9
10 grep -v '^#' "$BASE/repos.conf" | grep -v '^$' | while IFS='|' read -r name path desc mode; do
11 m="$CACHE/mirrors/$name.git"
12 if [ ! -d "$m" ]; then
13 echo "mirroring $name"
14 git clone --quiet --mirror "$path" "$m"
15 git -C "$m" config gc.auto 0
16 # small packfiles: Cloudflare Pages rejects files over 25MB
17 git -C "$m" repack -a -d -q --max-pack-size=20m
18 else
19 # repos.conf is the source of truth for where a repo lives; a mirror
20 # made when it pointed elsewhere (the ~/git bare layer, before
21 # 2026-09-20) follows it here rather than fetching from a stale path.
22 git -C "$m" remote set-url origin "$path"
23 git -C "$m" fetch --quiet --prune origin
24 fi
25 done
26
27 python3 "$BASE/generate.py"
28
29 grep -v '^#' "$BASE/repos.conf" | grep -v '^$' | while IFS='|' read -r name path desc mode; do
30 if [ "$mode" = "clone" ]; then
31 m="$CACHE/mirrors/$name.git"
32 # no loose objects: Cloudflare mangles them in transit; packs survive
33 git -C "$m" repack -a -d -q --max-pack-size=20m
34 git -C "$m" update-server-info
35 cp -al "$m" "$CACHE/out/$name.git"
36 fi
37 done
38
39 echo "site built at $CACHE/out"