#!/usr/bin/env bash # Licence: LGPLv2 out_dir="html_history_listing" git_dir="." function Help() { if [[ $1 != "" ]]; then echo "Error: $*" fi cat < -o [-v] [-h] A shell script for producing a nice html listing for the history of each file. The script creates a index.html file that contains a link per html file in given git repository. Each linked html file contains the change log for one file contained in the repository. EOF exit 1 } while getopts "hg:o:" opt; do case ${opt} in h) Help ;; g) git_dir=$OPTARG ;; o) out_dir=$OPTARG ;; v) set -x export PS4='+(${BASH_SOURCE}:${LINENO})' VERBOSE=1 ;; *) Help "Invalid option" ;; esac done out_dir=$(realpath "${out_dir}") git_dir=$(realpath "${git_dir}") if [[ ! -d "$git_dir" ]]; then Help "git repo directory ${git_dir} does not exist" fi script_dir=$(dirname $0) script_dir=$(realpath "${script_dir}") html_index="" #if [[ -d "$out_dir" ]]; then # rm -rf "$out_dir" #fi cat <

History listing for file: ${f}

" >${out_html_path} git log --color=always --follow --pretty=fuller -p --ignore-cr-at-eol --raw ${f} | ${script_dir}/ansi2html.sh | sed -E 's/^commit (([0-9a-f]{8})[0-9a-f]+)<\/span>/commit \1<\/span>/' >${out_html_path} blame_link_path="${f}.blame.html" out_blame_html_path="${out_file}.blame.html" cross_link_path=$(basename "${link_path}") #git blame --color-lines ${f} | ${script_dir}/ansi2html.sh >${out_blame_html_path} git blame --root --color-lines ${f} | ${script_dir}/ansi2html.sh | sed -E "s@^([0-9a-f]+)@\2@" | sed -E "s@^([0-9a-f]+)@\1@" >${out_blame_html_path} html_index="${html_index}
  • ${f} Log Blame " done echo "${html_prefix}${html_index}" >${out_dir}/index.html