dot

packages and services management
Log | Files | Refs | README

commit 386fc39374f629b7254a1c23f98dcc94926e9d61
parent 9ea3fecce8159a14e9db027d7e77d1600ad7b583
Author: Josuah Demangeon <mail@josuah.net>
Date:   Sat, 18 Nov 2017 10:21:35 +0100

renamed git-http to git-html

Diffstat:
Abin/git-html | 44++++++++++++++++++++++++++++++++++++++++++++
Dbin/git-http | 45---------------------------------------------
Aman/git-html.1 | 33+++++++++++++++++++++++++++++++++
Dman/git-index.1 | 33---------------------------------
4 files changed, 77 insertions(+), 78 deletions(-)

diff --git a/bin/git-html b/bin/git-html @@ -0,0 +1,44 @@ +#!/bin/sh +# add index.html and commit/%H.html inside of a git bare repository + +export LC_COLLATE=C + +NAME=$(cd "$1" && pwd | sed 's|.*/||') +HEADER="<!doctype html> +<title>$NAME</title> +<meta charset="utf-8"/> +<style> pre { width: 80ch; margin: 4em auto 4em auto; } </style> +<pre> +<h1><a href="..">..</a>/$NAME</h1> +<b>GIT_SMART_HTTP=0 git clone http://git.josuah.net/$NAME</b> +" + +{ + printf '%s\n\n' "$HEADER" + git -C "$1" ls-tree -r --name-only master | sort | sed 's|^| |' + printf '\n\n' + git -C "$1" log --graph --date=short --decorate --tags --stat \ + --branches --remotes | + sed -r -e 's|&|\&amp;|g' \ + -e 's|<|\&lt;|g' \ + -e 's|([0-9a-f]{8})[0-9a-f]{32}|<a href="commit/&.html">\1</a>|' + printf '</pre>\n' +} > "$1/index.html" + +mkdir -p "$1/commit" +for commit in $(git -C "$1" log --format='%H') +do + [ -f "$1/commit/$commit.html" ] && continue + printf '%s\n' "$commit" + printf '%s\n' "$HEADER" > "$1/commit/$commit.html" + git -C "$1" show -U3 "$commit" | sed >> "$1/commit/$commit.html" \ + -e ' s|&|\&amp;|g' \ + -e ' s|<|\&lt;|g' \ + -e ' s|^[A-Z][a-z]*:|<b>&</b>|' \ + -e '/^commit/ s|.*|<b>&</b>|' \ + -e '/^diff/ s|.*|<b>&</b>|' \ + -e '/^+/ s|.*|<span style="color: #0f0;">&</span>|' \ + -e '/^-/ s|.*|<span style="color: #f00;">&</span>|' \ + -e '/^@/ s|.*|<span style="color: #00f;">&</span>|' + printf '</pre>\n' >> "$1/commit/$commit.html" +done diff --git a/bin/git-http b/bin/git-http @@ -1,45 +0,0 @@ -#!/bin/sh -# add index.html and commit/%H.html inside of a git bare repository - -export LC_COLLATE=C - -NAME=$(cd "$1" && pwd | sed 's|.*/||') - -HEADER="<!doctype html> -<title>$NAME</title> -<meta charset="utf-8"/> -<style> pre { width: 80ch; margin: 4em auto 4em auto; } </style> -<pre> -<h1><a href="..">..</a>/$NAME</h1> -<b>GIT_SMART_HTTP=0 git clone http://git.josuah.net/$NAME</b> -" - -{ - printf '%s\n\n' "$HEADER" - git -C "$1" ls-tree -r --name-only master | sort | sed 's|^| |' - printf '\n\n' - git -C "$1" log --graph --date=short --decorate --tags --stat \ - --branches --remotes | - sed -r -e 's|&|\&amp;|g' \ - -e 's|<|\&lt;|g' \ - -e 's|([0-9a-f]{8})[0-9a-f]{32}|<a href="commit/&.html">\1</a>|' - printf '</pre>\n' -} > "$1/index.html" - -mkdir -p "$1/commit" -for commit in $(git -C "$1" log --format='%H') -do - [ -f "$1/commit/$commit.html" ] && continue - printf '%s\n' "$commit" - printf '%s\n' "$HEADER" > "$1/commit/$commit.html" - git -C "$1" show -U3 "$commit" | sed >> "$1/commit/$commit.html" \ - -e ' s|&|\&amp;|g' \ - -e ' s|<|\&lt;|g' \ - -e ' s|^[A-Z][a-z]*:|<b>&</b>|' \ - -e '/^commit/ s|.*|<b>&</b>|' \ - -e '/^diff/ s|.*|<b>&</b>|' \ - -e '/^+/ s|.*|<span style="color: #0f0;">&</span>|' \ - -e '/^-/ s|.*|<span style="color: #f00;">&</span>|' \ - -e '/^@/ s|.*|<span style="color: #00f;">&</span>|' - printf '</pre>\n' >> "$1/commit/$commit.html" -done diff --git a/man/git-html.1 b/man/git-html.1 @@ -0,0 +1,33 @@ +.Dd mar 23, 2017 +.Dt GIT-HTML +.Os +.Sh NAME +.Nm git-html +.Nd generate static website using the git binary +.Sh SYNOPSIS +.Nm +.Ar repository +.Op Ar description +.Sh DESCRIPTION +The +.Nm +script creates a static page listing the commits of a git repository, +as well as one page per commit. +The build process is incremential so that it can be triggered at every +commit without large overhead. +.Pp +It can be invoked within the +.Pa post-update +hook to update the listing every time commits are pushed to the repo. +.Pp +The first argument is treated as a path to a repository. +.Sh FILES +.Bl -tag -width indent +.It Pa ./repository/index.html +An +.Pa index.html +file will be created in the repository directory, containing a list of +the files and the commits. +.It Pa ./repository/commit/4279dbc3735e1e38bf33120c9234640d99fee650.html +One html page per commit is created. +.El diff --git a/man/git-index.1 b/man/git-index.1 @@ -1,33 +0,0 @@ -.Dd mar 23, 2017 -.Dt GIT-HTTP -.Os -.Sh NAME -.Nm git-http -.Nd generate static website using the git binary -.Sh SYNOPSIS -.Nm -.Ar repository -.Op Ar description -.Sh DESCRIPTION -The -.Nm -script creates a static page listing the commits of a git repository, -as well as one page per commit. -The build process is incremential so that it can be triggered at every -commit without large overhead. -.Pp -It can be invoked within the -.Pa post-update -hook to update the listing every time commits are pushed to the repo. -.Pp -The first argument is treated as a path to a repository. -.Sh FILES -.Bl -tag -width indent -.It Pa ./repository/index.html -An -.Pa index.html -file will be created in the repository directory, containing a list of -the files and the commits. -.It Pa ./repository/commit/4279dbc3735e1e38bf33120c9234640d99fee650.html -One html page per commit is created. -.El