This guide assumes that you are familiar with
got and
which are located at /var/www/got/public/
.
This guide also assumes that you have properly configured
nsd with git
as a
NOTE: Replace all the instances of example.com with your domain.
!!Overview
is a simple static page generator for git.
It generates static HTML pages for a git repository.
!!!Advantages
It is written in C (with support for pledge and unveil).
The code base is very simple and is about 1.5K LOC.
Work very well with text-based browsers such as lynx and w3m.
No CGI or dynamic code is required.
No configuration required.
Atom feed of the commit and tags/refs.
!!!Disadvantages
Depends on libgit2.
Not suitable for large repo with many files, commits(2000+), or branches.
Does not support features like:
Snapshot tarballs per commit.
File tree per commit.
History log of branches diverged from HEAD.
Stats (git shortlog -s).
This is by design, just use git locally.
!!Installation
Install the dependency:
$ doas pkg_add libgit2
Get the latest release of stagit from
here.
At the time of writing, it was 1.2.
$ ftp https://codemadness.org/releases/stagit/stagit-1.2.tar.gz
$ ftp https://codemadness.org/releases/stagit/stagit-1.2.tar.gz.sha256
$ sha256 -C stagit-1.2.tar.gz.sha256 stagit-1.2.tar.gz
(SHA256) stagit-1.2.tar.gz: OK
Extract, compile and install:
$ tar xvzf stagit-1.2.tar.gz
$ cd stagit-1.2
$ make
$ doas make install
If you get any error like this:
stagit.c:1239:19: error: use of undeclared identifier 'GIT_OPT_SET_OWNER_VALIDATION'
git_libgit2_opts(GIT_OPT_SET_OWNER_VALIDATION, 0);
^
Edit Makefile
and uncomment this line:
STAGIT_CFLAGS += -DGIT_OPT_SET_OWNER_VALIDATION=-1
Now you should be able make and install without any error.
$ make
$ doas make install
!!Configuration
Edit /etc/httpd.conf
and add this section.
server "git.example.com" {
listen on * port 80
root "/htdocs/git.example.com"
location "/.well-known/acme-challenge/*" {
root "/acme"
request strip 2
}
}
Restart httpd
:
$ doas rcctl restart httpd
For ssl/tls upport, configure acme-client and relayd.
!!Generate static site
$ doas mkdir -p /var/www/htdocs/git.example.com
$ doas cp favicon.png logo.png style.css /var/www/htdocs/git.example.com/
$ cd /var/www/htdocs/git.example.com
$ doas touch create.sh
$ doas chmod +x create.sh
Edit create.sh and copy-paste the code below:
#!/bin/sh
reposdir="/var/www/got/public"
curdir="/var/www/htdocs/git.example.com"
stagit-index "${reposdir}/"*/ > "${curdir}/index.html"
for dir in "${reposdir}/"*/; do
r=$(basename "${dir}")
d=$(basename "${dir}" ".git")
printf "%25s... " "${d}"
mkdir -p "${curdir}/${d}"
cd "${curdir}/${d}" || continue
stagit -c ".cache" -u "https://git.example.com/$d/" "${reposdir}/${r}"
ln -sf log.html index.html
ln -sf ../style.css style.css
ln -sf ../logo.png logo.png
ln -sf ../favicon.png favicon.png
echo "done"
done
Run create.sh
to generate the html pages for all the repos:
$ doas ./create.sh
Now you can visit http://git.example.com
.
NOTE: You have to run create.sh
every time you make changes to the repos.
To change the logo, replace the default favicon.png
and logo.png
with
your 32x32 logo and regenerate the html files.
!!Add Metadata
Add description
, owner
and url
files to all the repos.
-
description - description of the repo.
-
owner - owner name of the repo.
-
url - clone URL of the repo, for example: git://git.example.com/project
See Also: