README 4.4 KB

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