sty, doku, hooks init

This commit is contained in:
André Hilbig 2016-06-23 15:31:18 +02:00
parent 97acb5db56
commit 70d2a68ced
5 changed files with 407 additions and 0 deletions

146
dokumentation.tex Normal file
View File

@ -0,0 +1,146 @@
\documentclass[a4paper]{ltxdoc}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english,ngerman]{babel}
\usepackage{xparse,xargs}
\usepackage{newfloat}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\definecolor{blau}{rgb}{0,0,0.75}
\definecolor{orange}{rgb}{0.8,0.3,0}
%\usepackage[%
% backend=biber,
% sortlocale=de_DE,
% style=authoryear,
% bibencoding=UTF8,
% block=space,
% autocite=inline,
% language=ngerman,
%]{biblatex}
%\addglobalbib{.bib}
%\renewcommand*{\mkbibnamelast}{\textsc}
%\DeclareCiteCommand{\citeauthorfull}
% {%
% \boolfalse{citetracker}%
% \boolfalse{pagetracker}%
% \usebibmacro{prenote}}
% {\ifciteindex%
% {\indexnames{labelname}}
% {}%
% \printnames[first-last]{author}}
% {\multicitedelim}
% {\usebibmacro{postnote}}
\usepackage{hyperref}
\hypersetup{%
pdftitle = {\LaTeX-package for reading git commit info for specific files}
pdfsubject = {}, %
pdfkeywords = {LaTeX,CTAN,git,fileinfo,version,control}, %
pdfauthor = {Andr\'e Hilbig}, %
colorlinks = true, %
hypertexnames = true, %
linkcolor=blau, %
filecolor=orange, %
citecolor=blau, %
menucolor=orange, %
urlcolor=orange, %
breaklinks=true %
}
\usepackage{graphics,graphicx,textcomp}
\usepackage{placeins,float,caption,prettyref}
\usepackage{pdfpages,listings,xspace}
\usepackage{amssymb,multicol,pdflscape}
\usepackage[german=guillemets]{csquotes}
\newrefformat{sec}{Abschnitt\,\ref{#1}, S.\,\pageref{#1}}
\newrefformat{paket}{Paket~\ref{#1}, S.\,\pageref{#1}}
\newrefformat{klasse}{Klasse~\ref{#1}, S.\,\pageref{#1}}
\newrefformat{fig}{Abb.\,\ref{#1}}
\newrefformat{tab}{Tab.\,\ref{#1}}
\newrefformat{bsp}{Bsp.\,\ref{#1}, S.\,\pageref{#1}}
\newcommand{\refMacro}[1]{Makro \texttt{\textbackslash#1}, S.\,\pageref{#1}}
\DeclareFloatingEnvironment[name={Bsp.},
listname={Beispielverzeichnis}, within=section]{example}
\floatstyle{ruled}
\restylefloat{example}
\NewDocumentEnvironment{beispiel}{o o m}{
\begin{example}[ht!]
\centering
\vspace{0.2cm}
\IfNoValueTF{#2}{
\caption{#3}
}{
\caption[#2]{#3}
}
}{
\IfNoValueTF{#1}{
\label{\theexample}
}{
\label{#1}
}
\vspace{0.2cm}
\end{example}
}
\DisableCrossrefs
\makeatletter
\makeatother
\lstset{ %
language=[LaTeX]TeX,
basicstyle=\small,
numbers=left,
numberstyle=\footnotesize,
stepnumber=1,
numbersep=5pt,
backgroundcolor=\color{Peach!30!white},
showspaces=false,
showstringspaces=false,
showtabs=false,
frame=single,
tabsize=2,
resetmargins=true,
captionpos=b,
title={},
caption={},
breaklines=true,
breakautoindent=true,
prebreak=\mbox{ $\curvearrowright$},
postbreak=\mbox{$\rightsquigarrow$ },
linewidth=\columnwidth,
breakatwhitespace=true,
numberstyle=\tiny\color{gray},
keywordstyle=\color{OliveGreen}\textbf,
commentstyle=\color{gray}\itshape,
stringstyle=\color{mauve},
morekeywords={
minisec, subsection, glqq, grqq, euro, Name, Vorname, Street,
Plz, Stadt, MeinBeruf, EMail, Tel, Mobile, Sta, GebDatum, ID,
Anhang, includepdf, includepdfmerge, cventry, cvlistitem,
cvlanguage, definecolor, maketitle, makePerson, cp, ln, mkdir,
todayOrt, todayDatum,
},
literate=%
{Ö}{{\"O}}1
{Ä}{{\"A}}1
{Ü}{{\"U}}1
{ß}{\ss}2
{ü}{{\"u}}1
{ä}{{\"a}}1
{ö}{{\"o}}1
{»}{{\frqq}}4
{«}{{\flqq}}4
{~}{$\sim$}1
}
\xspaceaddexceptions{\guillemotright,\guillemotleft}
\CheckSum{0}
\author{André Hilbig}
\begin{document}
\title{Gitfile-Info}
%\clearpage
%\addcontentsline{toc}{section}{Literatur}
%\printbibliography
\end{document}

69
gfi-run Executable file
View File

@ -0,0 +1,69 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# -*- mode:python -*-
import os
import sys
import time
import codecs
from git import Repo
import locale
locale.setlocale(locale.LC_ALL, 'de_DE')
pathrepo = os.getcwd()
repo = Repo(pathrepo)
assert not repo.bare
git = repo.git
headcommit = repo.head.commit
index = repo.index
if len(sys.argv) <= 1:
commFiles = git.ls_files(full_name=True).split("\n")
#commit = git.log('-1', format='%h').rstrip()
#cmt = subprocess.check_output('git log -1 --format="%s" ', shell=True).decode("utf-8").rstrip()
for fl in commFiles:
flname, flext = os.path.splitext(fl)
if flext == '.tex':
rawdate = int(git.log('-1', fl, pretty='format:"%at"').split('"')[1])
date = [time.strftime("%d. %B %Y %H:%M", time.gmtime(rawdate)),
time.strftime("%d", time.gmtime(rawdate)),
time.strftime("%m", time.gmtime(rawdate)),
time.strftime("%Y", time.gmtime(rawdate)),
time.strftime("%H", time.gmtime(rawdate)),
time.strftime("%M", time.gmtime(rawdate))]
author = [git.log('-1', fl, pretty='format:"%an"').split('"')[1],
git.log('-1', fl, pretty='format:"%ae"').split('"')[1]]
commit = [git.log('-1', fl, pretty='format:"%H"').split('"')[1],
git.log('-1', fl, pretty='format:"%h"').split('"')[1]]
f = codecs.open(flname+".gfi", "w", encoding="utf-8")
f.write("% gitfile-info control file\n")
f.write("\\gfiSetDate{" + date[1] + "}{" + date[2] + "}{" + date[3] + "}{"
+ date[4] + "}{" + date[5] + "}{" + date[0] + "}\n")
f.write("\\gfiSetAuthor{" + author[0] + "}{" + author[1] + "}\n")
f.write("\\gfiSetCommit{" + commit[0] + "}{" + commit[1] + "}")
#print("\\gfiSet{" + date + "}{" + author + "}{" + commit + "}")
f.close
else:
fl = sys.argv[1]
flname, flext = os.path.splitext(fl)
rawdate = int(git.log('-1', fl, pretty='format:"%at"').split('"')[1])
date = [time.strftime("%d. %B %Y %H:%M", time.gmtime(rawdate)),
time.strftime("%d", time.gmtime(rawdate)),
time.strftime("%m", time.gmtime(rawdate)),
time.strftime("%Y", time.gmtime(rawdate)),
time.strftime("%H", time.gmtime(rawdate)),
time.strftime("%M", time.gmtime(rawdate))]
author = [git.log('-1', fl, pretty='format:"%an"').split('"')[1],
git.log('-1', fl, pretty='format:"%ae"').split('"')[1]]
commit = [git.log('-1', fl, pretty='format:"%H"').split('"')[1],
git.log('-1', fl, pretty='format:"%h"').split('"')[1]]
f = codecs.open(flname+".gfi", "w", encoding="utf-8")
f.write("% gitfile-info control file\n")
f.write("\\gfiSetDate{" + date[1] + "}{" + date[2] + "}{" + date[3] + "}{"
+ date[4] + "}{" + date[5] + "}{" + date[0] + "}\n")
f.write("\\gfiSetAuthor{" + author[0] + "}{" + author[1] + "}\n")
f.write("\\gfiSetCommit{" + commit[0] + "}{" + commit[1] + "}")
#print("\\gfiSet{" + date + "}{" + author + "}{" + commit + "}")
f.close

106
gitfile-info.sty Normal file
View File

@ -0,0 +1,106 @@
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{gitfile-info}
[2016/06/22 v0.1 read file infos of one specific tex-file]
\RequirePackage{ifthen}
\RequirePackage{currfile}
\RequirePackage{xparse}
\RequirePackage{tcolorbox}
\tcbuselibrary{fitting, skins, breakable}
\tcbset{center title,fonttitle=\bfseries\sffamily}
\RequirePackage{hyperref}
\providecommand{\gfiGetDay}{gfi day}
\providecommand{\gfiGetMonth}{gfi month}
\providecommand{\gfiGetYear}{gfi year}
\providecommand{\gfiGetHour}{gfi hour}
\providecommand{\gfiGetMin}{gfi min}
\providecommand{\gfiGetAuthorName}{gfi author name}
\providecommand{\gfiGetAuthorMail}{gfi author email}
\providecommand{\gfiGetDate}{gfi date}
\providecommand{\gfiGetCommit}{gfi commit}
\providecommand{\gfiGetCommitAbr}{gfi commit short}
\providecommand{\gfiSetDate}[6]{%
\renewcommand{\gfiGetDay}{#1}
\renewcommand{\gfiGetMonth}{#2}
\renewcommand{\gfiGetYear}{#3}
\renewcommand{\gfiGetMin}{#4}
\renewcommand{\gfiGetHour}{#5}
\renewcommand{\gfiGetDate}{#6}
}
\providecommand{\gfiSetAuthor}[2]{%
\renewcommand{\gfiGetAuthorName}{#1}
\renewcommand{\gfiGetAuthorMail}{#2}
}
\providecommand{\gfiSetCommit}[2]{%
\renewcommand{\gfiGetCommit}{#1}
\renewcommand{\gfiGetCommitAbr}{#2}
}
\newtcolorbox{gfiInfoBox}{%
every box on layer 2/.style={reset},%
breakable,%
title=\currfilename,%
enhanced,%
attach boxed title to top right={%
yshift=-2mm,%
xshift=-3mm,%
},%
boxed title style={%
drop fuzzy shadow,%
},%
fontupper=\small,%
before skip=2mm,after skip=3mm,%
boxrule=0.4pt,left=5mm,right=2mm,top=1mm,bottom=1mm,%
colback=yellow!50,%
colframe=yellow!20!black,%
sharp corners,rounded corners=southeast,arc is angular,arc=3mm,%
underlay={%
\path[fill=tcbcol@back!80!black] ([yshift=3mm]interior.south east)--++(-0.4,-0.1)--++(0.1,-0.2);
\path[draw=tcbcol@frame,shorten <=-0.05mm,shorten >=-0.05mm] ([yshift=3mm]interior.south east)--++(-0.4,-0.1)--++(0.1,-0.2);
\path[fill=yellow!50!black,draw=none] (interior.south west) rectangle node[white,rotate=90]{\footnotesize\bfseries git} ([xshift=4mm]interior.north west);
},%
drop fuzzy shadow,%
}
\ProvideDocumentCommand{\gfiInfo}{O{none} O{none} O{none} O{gfiInfoBox}}{%
\begin{#4}
\textbf{Version:} \ifthenelse{\equal{#1}{none}}{\gfiGetCommit}{\gfiGetCommitAbr}\newline
\textbf{Stand:} \ifthenelse{\equal{#2}{none}}{\gfiGetDate}{#2}\newline
\textbf{Zuletzt bearbeitet von:}
\ifthenelse{\equal{#3}{none}}{\href{mailto:\gfiGetAuthorMail}{\gfiGetAuthorName}}{#3}
\end{#4}
}
\providecommand{\gfiCurrentConfig}{none}
\providecommand{\gfiInitJob}{%
\IfFileExists{\jobname.gfi}{%
\input{\jobname.gfi}
}{%
\@latex@warning@no@line{gitfile-info: No \jobname.gfi information-file given}
\@latex@warning@no@line{gitfile-info: All hooks and initialization run?}
}
}
\providecommand{\gfiInitInc}[1]{%
\IfFileExists{#1.gfi}{%
\input{#1.gfi}
}{%
\@latex@warning@no@line{gitfile-info: No #1.gfi information-file given}
\@latex@warning@no@line{gitfile-info: All hooks and initialization run?}
}
}
\AtBeginDocument{%
\gfiInitJob
}
\providecommand{\gfiInput}[1]{%
\gfiInitInc{#1}
\input{#1}
\gfiInitInc{\currfilebase}
}
\providecommand{\gfiInclude}[1]{%
\gfiInitInc{#1}
\include{#1}
\gfiInitInc{\currfilebase}
}

42
post-commit Executable file
View File

@ -0,0 +1,42 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# -*- mode:python -*-
import sys
import os
import time
import codecs
from git import Repo
import locale
locale.setlocale(locale.LC_ALL, 'de_DE')
pathrepo = os.getcwd()
repo = Repo(pathrepo)
assert not repo.bare
git = repo.git
headcommit = repo.head.commit
index = repo.index
commFiles = git.diff_tree('-r', 'HEAD', no_commit_id=True, name_only=True).split("\n")
date = [time.strftime("%d. %B %Y %H:%M", time.gmtime(headcommit.authored_date)),
time.strftime("%d", time.gmtime(headcommit.authored_date)),
time.strftime("%m", time.gmtime(headcommit.authored_date)),
time.strftime("%Y", time.gmtime(headcommit.authored_date)),
time.strftime("%H", time.gmtime(headcommit.authored_date)),
time.strftime("%M", time.gmtime(headcommit.authored_date))]
author = [headcommit.author.name, headcommit.author.email]
commit = [headcommit.hexsha, headcommit.hexsha[:6]]
#commit = git.log('-1', format='%h').rstrip()
#cmt = subprocess.check_output('git log -1 --format="%s" ', shell=True).decode("utf-8").rstrip()
for fl in commFiles:
flname, flext = os.path.splitext(fl)
if flext == '.tex':
f = codecs.open(flname+".gfi", "w", encoding="utf-8")
f.write("% gitfile-info control file\n")
f.write("\\gfiSetDate{" + date[1] + "}{" + date[2] + "}{" + date[3] + "}{"
+ date[4] + "}{" + date[5] + "}{" + date[0] + "}\n")
f.write("\\gfiSetAuthor{" + author[0] + "}{" + author[1] + "}\n")
f.write("\\gfiSetCommit{" + commit[0] + "}{" + commit[1] + "}")
#print("\\gfiSet{" + date + "}{" + author + "}{" + commit + "}")
f.close

44
post-merge Executable file
View File

@ -0,0 +1,44 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# -*- mode:python -*-
import os
import time
import codecs
from git import Repo
import locale
locale.setlocale(locale.LC_ALL, 'de_DE')
pathrepo = os.getcwd()
repo = Repo(pathrepo)
assert not repo.bare
git = repo.git
headcommit = repo.head.commit
index = repo.index
commFiles = git.diff_tree('-r', 'ORIG_HEAD', 'HEAD', no_commit_id=True, name_only=True).split("\n")
#commit = git.log('-1', format='%h').rstrip()
#cmt = subprocess.check_output('git log -1 --format="%s" ', shell=True).decode("utf-8").rstrip()
for fl in commFiles:
flname, flext = os.path.splitext(fl)
if flext == '.tex':
rawdate = int(git.log('-1', fl, pretty='format:"%at"').split('"')[1])
date = [time.strftime("%d. %B %Y %H:%M", time.gmtime(rawdate)),
time.strftime("%d", time.gmtime(rawdate)),
time.strftime("%m", time.gmtime(rawdate)),
time.strftime("%Y", time.gmtime(rawdate)),
time.strftime("%H", time.gmtime(rawdate)),
time.strftime("%M", time.gmtime(rawdate))]
author = [git.log('-1', fl, pretty='format:"%an"').split('"')[1],
git.log('-1', fl, pretty='format:"%ae"').split('"')[1]]
commit = [git.log('-1', fl, pretty='format:"%H"').split('"')[1],
git.log('-1', fl, pretty='format:"%h"').split('"')[1]]
f = codecs.open(flname+".gfi", "w", encoding="utf-8")
f.write("% gitfile-info control file\n")
f.write("\\gfiSetDate{" + date[1] + "}{" + date[2] + "}{" + date[3] + "}{"
+ date[4] + "}{" + date[5] + "}{" + date[0] + "}\n")
f.write("\\gfiSetAuthor{" + author[0] + "}{" + author[1] + "}\n")
f.write("\\gfiSetCommit{" + commit[0] + "}{" + commit[1] + "}")
#print("\\gfiSet{" + date + "}{" + author + "}{" + commit + "}")
f.close