No frills static page generator for Git repositories

git clone

  1# depp
  3No frills static page generator for Git repositories.
  5## Motivation
  7Dynamic git repository viewers like [cgit][cgit website] or
  8[gitweb][gitweb website] inherit the general disadvantages of dynamic
  9web applications (resource consumption, security concerns, …). For this
 10reason, static page generators for git (e.g. [git-arr][git-arr website]
 11or [stagit][stagit website]) emerged recently. However, these page
 12generators are usually not compatible with large repository as they
 13generate lots of HTML files (e.g. one for each commit).
 15Contrary to existing static page generator approaches, this software
 16does not strive to be a fully featured git browser for the web. Instead,
 17the idea is to provide a quick overview for a given repository, thereby
 18allowing users to decide whether it is interesting enough to be cloned.
 19As such, this software does intentionally not provide a web frontend for
 20existing tools like `git-log(1)`, `git-blame(1)`, et cetera. If more
 21information is needed, the user should simply clone the repository and
 22use `git(1)` as usual.
 24## Status
 26I use this for my own Git server, it presently doesn't have any known
 27bugs and the currently implemented feature set works quite well.
 29## Dependencies
 31This software has the following dependencies:
 33* [libgit2][libgit2 website] >= 1.5
 34* [Go][go website] >= 1.16.0 (`embed` package needed)
 35* C compiler, pkg-config, … for linking against libgit2
 37## Installation
 39Clone the repository and ran the following commands:
 41    $ make
 42    $ sudo make install
 44This will install two binaries: `depp` for generating HTML files on a
 45per-repository basis and `depp-index` which can optionally be used to
 46generate an HTML index page for listing all hosted git repositories.
 47Both commands are further described in the provided man page, a usage
 48example is provided below.
 50## Usage
 52Assuming you have a web server serving files located at
 53`/var/www/htdocs/`, you want 10 commits on the index
 54page, and the repository can be cloned via `git://`:
 56	$ depp -c 10 -u git:// \
 57		-d /var/www/htdocs/ \
 58		<path to git repository to generate pages for>
 60To automate this process, create a `post-receive` hook for your
 61repository on your git server, see `githooks(5)` for more information.
 62Keep in mind that the repository page itself only needs to be regenerated
 63if the default branch is pushed, since only the default branch is
 64considered by `depp`. As such, an exemplary `post-receive` hook may look
 65as follows:
 67	#!/bin/sh
 69	repo=$(git rev-parse --absolute-git-dir)
 70	name=${repo##*/}
 72	rebuild=0
 73	defref=$(git symbolic-ref HEAD)
 74	while read local_ref local_sha remote_ref remote_sha; do
 75		if [ "${remote_ref}" = "${defref}" ]; then
 76			rebuild=1
 77			break
 78		fi
 79	done
 81	# Only rebuild if a ref for the default ref was pushed
 82	[ ${rebuild} -eq 1 ] || exit 0
 84	depp -u "git://${name}" \
 85		-d "/var/www/htdocs/${name}" .
 87If usage of `deep-index` is also desired, the index page can either be
 88rebuild as part of the `post-receive` hook or in a separate cronjob.
 90## README Rendering
 92Rendering README files written in a chosen markup language (e.g.
 93markdown) is supported. This is achieved by including an executable file
 94called `git-render-readme` in the bare Git repository. When executed,
 95this file receives the README content on standard input and must write
 96plain HTML to standard output.
 98As an example, consider the following `git-render-readme` script which
 99uses the `markdown(1)` program provided by the [discount][discount website]
100Markdown implementation:
102	#!/bin/sh
103	exec markdown -f autolink
105## Caveats
107Existing HTML files are not tracked, thus the generated HTML for files
108removed from the repository `HEAD` is not automatically removed from
109the depp destination directory. In order to be able to identify HTML
110files not touched by depp the `mtime` and `atime` of `index.html` is set
111to a time *before* the generation of any HTML files on each invocation.
112This allows removing generated HTML for files removed from the
113repository by invoking the following command from the depp destination
116	$ find . -not -newer index.html -not -path ./index.html -type f \
117		-exec rm {} \+ 2>/dev/null
119The above `find(1)` invocation can conveniently be executed from a
120cronjob. Unfortunately, this command does not remove empty directories,
121these need to be handled separately (some `find(1)` implementations
122support `-empty` for this purpose).
124## License
126This program is free software: you can redistribute it and/or modify it
127under the terms of the GNU General Public License as published by the
128Free Software Foundation, either version 3 of the License, or (at your
129option) any later version.
131This program is distributed in the hope that it will be useful, but
132WITHOUT ANY WARRANTY; without even the implied warranty of
134Public License for more details.
136You should have received a copy of the GNU General Public License along
137with this program. If not, see <>.
139[cgit website]:
140[gitweb website]:
141[git-arr website]:
142[stagit website]:
143[libgit2 website]:
144[go website]:
145[discount website]:
146[git2go repo]:
147[git2go build]: