stagit

Personal fork of stagit.
git clone git://git.samirparikh.com/stagit
Log | Files | Refs | README | LICENSE

README (4699B) - raw


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