stagit-fork

static git page generator - fork with some customisations
git clone https://git.ortlepp.eu/stagit-fork.git/
Log | Files | Refs | README | LICENSE

README (4433B)


      1 stagit
      2 ------
      3 
      4 static git page generator.
      5 
      6 It generates static HTML pages for a git repository.
      7 
      8 
      9 /!\  This repository is a fork and contains some customisations
     10      The original code is here: http://codemadness.org/git/stagit/
     11 
     12 
     13 Usage
     14 -----
     15 
     16 Make files per repository:
     17 
     18 	$ mkdir -p htmldir && cd htmldir
     19 	$ stagit path-to-repo
     20 
     21 Make index file for repositories:
     22 
     23 	$ stagit-index repodir1 repodir2 repodir3 > index.html
     24 
     25 
     26 Build and install
     27 -----------------
     28 
     29 $ make
     30 # make install
     31 
     32 
     33 Dependencies
     34 ------------
     35 
     36 - C compiler (C99).
     37 - libc (tested with OpenBSD, FreeBSD, NetBSD, Linux: glibc and musl).
     38 - libgit2 (v0.22+).
     39 - POSIX make (optional).
     40 
     41 
     42 Documentation
     43 -------------
     44 
     45 See man pages: stagit(1) and stagit-index(1).
     46 
     47 
     48 Building a static binary
     49 ------------------------
     50 
     51 It may be useful to build static binaries, for example to run in a chroot.
     52 
     53 It can be done like this at the time of writing (v0.24):
     54 
     55 cd libgit2-src
     56 
     57 # change the options in the CMake file: CMakeLists.txt
     58 BUILD_SHARED_LIBS to OFF (static)
     59 CURL to OFF              (not needed)
     60 USE_SSH OFF              (not needed)
     61 THREADSAFE OFF           (not needed)
     62 USE_OPENSSL OFF          (not needed, use builtin)
     63 
     64 mkdir -p build && cd build
     65 cmake ../
     66 make
     67 make install
     68 
     69 
     70 Extract owner field from git config
     71 -----------------------------------
     72 
     73 A way to extract the gitweb owner for example in the format:
     74 
     75 	[gitweb]
     76 		owner = Name here
     77 
     78 Script:
     79 
     80 	#!/bin/sh
     81 	awk '/^[ 	]*owner[ 	]=/ {
     82 		sub(/^[^=]*=[ 	]*/, "");
     83 		print $0;
     84 	}'
     85 
     86 
     87 Set clone url for a directory of repos
     88 --------------------------------------
     89 	#!/bin/sh
     90 	cd "$dir"
     91 	for i in *; do
     92 		test -d "$i" && echo "git://git.codemadness.org/$i" > "$i/url"
     93 	done
     94 
     95 
     96 Update files on git push
     97 ------------------------
     98 
     99 Using a post-receive hook the static files can be automatically updated.
    100 Keep in mind git push -f can change the history and the commits may need
    101 to be recreated. This is because stagit checks if a commit file already
    102 exists. It also has a cache (-c) option which can conflict with the new
    103 history. See stagit(1).
    104 
    105 git post-receive hook (repo/.git/hooks/post-receive):
    106 
    107 	#!/bin/sh
    108 	# detect git push -f
    109 	force=0
    110 	while read -r old new ref; do
    111 		hasrevs=$(git rev-list "$old" "^$new" | sed 1q)
    112 		if test -n "$hasrevs"; then
    113 			force=1
    114 			break
    115 		fi
    116 	done
    117 
    118 	# remove commits and .cache on git push -f
    119 	#if test "$force" = "1"; then
    120 	# ...
    121 	#fi
    122 
    123 	# see example_create.sh for normal creation of the files.
    124 
    125 
    126 Create .tar.gz archives by tag
    127 ------------------------------
    128 	#!/bin/sh
    129 	name="stagit"
    130 	mkdir -p archives
    131 	git tag -l | while read -r t; do
    132 		f="archives/${name}-$(echo "${t}" | tr '/' '_').tar.gz"
    133 		test -f "${f}" && continue
    134 		git archive \
    135 			--format tar.gz \
    136 			--prefix "${t}/" \
    137 			-o "${f}" \
    138 			-- \
    139 			"${t}"
    140 	done
    141 
    142 
    143 Features
    144 --------
    145 
    146 - Log of all commits from HEAD.
    147 - Log and diffstat per commit.
    148 - Show file tree with linkable line numbers.
    149 - Show references: local branches and tags.
    150 - Detect README and LICENSE file from HEAD and link it as a webpage.
    151 - Detect submodules (.gitmodules file) from HEAD and link it as a webpage.
    152 - Atom feed log (atom.xml).
    153 - Make index page for multiple repositories with stagit-index.
    154 - After generating the pages (relatively slow) serving the files is very fast,
    155   simple and requires little resources (because the content is static), only
    156   a HTTP file server is required.
    157 - Usable with text-browsers such as dillo, links, lynx and w3m.
    158 
    159 
    160 Cons
    161 ----
    162 
    163 - Not suitable for large repositories (2000+ commits), because diffstats are
    164   an expensive operation, the cache (-c flag) is a workaround for this in
    165   some cases.
    166 - Not suitable for large repositories with many files, because all files are
    167   written for each execution of stagit. This is because stagit shows the lines
    168   of textfiles and there is no "cache" for file metadata (this would add more
    169   complexity to the code).
    170 - Not suitable for repositories with many branches, a quite linear history is
    171   assumed (from HEAD).
    172 
    173   In these cases it is better to just use cgit or possibly change stagit to
    174   run as a CGI program.
    175 
    176 - Relatively slow to run the first time (about 3 seconds for sbase,
    177   1500+ commits), incremental updates are faster.
    178 - Does not support some of the dynamic features cgit has, like:
    179   - Snapshot tarballs per commit.
    180   - File tree per commit.
    181   - History log of branches diverged from HEAD.
    182   - Stats (git shortlog -s).
    183 
    184   This is by design, just use git locally.