gitserver

self-hosted git server tooling
git clone https://git.ryansepassi.com/git/gitserver.git
Log | Files | Refs | README

repo-index (693B)


      1 #!/bin/sh
      2 # Generate the default page for a stagit repository. Prefer the rendered
      3 # README and fall back to the commit log.
      4 set -eu
      5 
      6 out=${1:-}
      7 name=${2:-}
      8 [ -d "$out" ] && [ -n "$name" ] || { echo "usage: repo-index <output-dir> <repo-name>" >&2; exit 2; }
      9 case $name in *[!A-Za-z0-9._-]*) echo "invalid repo name: $name" >&2; exit 2 ;; esac
     10 
     11 target=/$name/log.html
     12 if [ -f "$out/file/README.md.html" ]; then
     13     target=/$name/file/README.md.html
     14 fi
     15 
     16 cat > "$out/index.html" <<EOF
     17 <!doctype html>
     18 <meta charset="utf-8">
     19 <meta http-equiv="refresh" content="0; url=$target">
     20 <link rel="canonical" href="$target">
     21 <title>Redirecting</title>
     22 <a href="$target">Continue to the repository</a>
     23 EOF