summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Bruhin <git@the-compiler.org>2013-08-14 16:38:06 +0200
committerFlorian Bruhin <git@the-compiler.org>2013-08-14 16:38:06 +0200
commit7b71c6c21b24f987ed89476cb0ea898d23c3f9a0 (patch)
treeb179d517680d9b0ce57338264f960f947e24f17f
downloadgit2latex-7b71c6c21b24f987ed89476cb0ea898d23c3f9a0.tar.gz
git2latex-7b71c6c21b24f987ed89476cb0ea898d23c3f9a0.zip
Old version
-rw-r--r--git2latex.sh44
1 files changed, 44 insertions, 0 deletions
diff --git a/git2latex.sh b/git2latex.sh
new file mode 100644
index 0000000..ae40c8d
--- /dev/null
+++ b/git2latex.sh
@@ -0,0 +1,44 @@
+#!/bin/bash
+
+bulletwidth=1
+idwidth=8
+datewidth=11
+
+if ! git rev-parse --git-dir &>/dev/null; then
+ echo "This does not seem to be a git repository!" >&2
+ exit 1
+fi
+
+if [[ $1 == --full ]]; then
+ echo '\documentclass[11pt,oneside,a4paper]{scrartcl}'
+# echo '\usepackage[utf8]{inputenc}'
+ echo '\usepackage[T1]{fontenc}'
+ echo '\usepackage{cmbright}'
+ echo '\usepackage{longtable}'
+ echo '\begin{document}'
+fi
+
+echo '\newlength\gittextlength'
+echo '\setlength\gittextlength{\linewidth}'
+echo '\addtolength\gittextlength{-'"$((bulletwidth + idwidth + datewidth))"'ex}'
+echo '\newenvironment{gitcommits}%'
+echo ' {\begin{longtable}{'"p{${bulletwidth}ex}p{${idwidth}ex}p{${datewidth}ex}"'p{\the\gittextlength}}}%'
+echo ' {\end{longtable}}'
+echo '\newcommand{\gitcommit}[3]{\textbullet & \textbf{#1} & \emph{#2} & #3 \\}'
+echo
+echo '\begin{gitcommits}'
+
+{ git log --date=short --format='format:%h %ad %s'; echo; } | \
+while read -r id date msg; do
+ msg=$(sed -e 's/\\/\\textbackslash/g' \
+ -e 's/~/\\textasciitilde/g' \
+ -e 's/\^/\\textasciicircum/g' \
+ -e 's/[%$_#{}&]/\\&/g' \
+ -e 's/[^\]\\text\(asciitilde\|asciicircum\|backslash\)/&{}/g' \
+ <<< "$msg")
+ echo " \\gitcommit{$id}{$date}{$msg}"
+done
+
+echo '\end{gitcommits}'
+
+[[ $1 == --full ]] && echo '\end{document}'