README.md (4927B) - raw


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