summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/support/gitfile-info/gitfile-info.dtx
blob: 4f817a85de1af8f3cc86d894e342222a2bf4e1a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
%\iffalse
% gitfile-info.dtx generated using makedtx version 0.94b (c) Nicola Talbot
% Command line args:
%   -macrocode "gfi-run.py"
%   -macrocode "post-commit.py"
%   -macrocode "post-merge.py"
%   -macrocode "gitfile-info.gfi"
%   -codetitle "Code"
%   -comment "gitfile-info.gfi"
%   -comment "gfi-run.py"
%   -comment "post-commit.py"
%   -comment "post-merge.py"
%   -doc "../dokumentation.tex"
%   -src "(.*)\.sty=>\1.sty"
%   -src "gfi-run.py=>gfi-run.py"
%   -src "post-commit.py=>post-commit.py"
%   -src "post-merge.py=>post-merge.py"
%   -src "gitfile-info.gfi=>gitfile-info.gfi"
%   -date "2019-04-09:19:53:54 -- Version 0.4"
%   -setambles "gitfile-info.gfi=>\nopreamble\nopostamble"
%   -setambles "gfi-run.py=>\nopreamble\nopostamble"
%   -setambles "post-commit.py=>\nopreamble\nopostamble"
%   -setambles "post-merge.py=>\nopreamble\nopostamble"
%   -author "André Hilbig, mail@andrehilbig.de"
%   gitfile-info
% Created on 2019-04-09:19:53:54 -- Version 0.4/4/9 19:53
%\fi
%\iffalse
%<*package>
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%</package>
%\fi
% \iffalse
% Doc-Source file to use with LaTeX2e
% Copyright (C) 2019-04-09:19:53:54 -- Version 0.4 André Hilbig, mail@andrehilbig.de, all rights reserved.
% \fi
% \iffalse
%<*driver>
\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} 

\begin{filecontents}{gitfile-info.bib}
	@electronic{gitpython,
		editor     = "gitpython-developers",
		month      = {Jun},
		year       = "2016",
		title      = "GitPython",
		subtitle	 = "GitPython is a python library used to interact with Git repositories",
		url        = {https://github.com/gitpython-developers/GitPython},
		urldate    = {2016-06-23},
	}
	@electronic{datenumber,
		author     = "J{\"o}rg-Michael Schr{\"o}der",
		month      = {Aug},
		year       = "2001",
		title      = "The datenumber.sty package v0.02",
		url        = {http://www.ctan.org/pkg/datenumber},
		urldate    = {2016-06-27},
	}
	@electronic{svninfo,
		author     = "Achim Brucker",
		month      = {Mar},
		year       = "2010",
		title      = "The svninfo package",
		url        = {http://www.ctan.org/pkg/svninfo},
		urldate    = {2016-06-27},
	}
	@electronic{gitinfo2,
		author     = "Brent Longborough",
		month      = {Nov},
		year       = "2015",
		title      = "gitinfo2.sty",
		subtitle   = "A package for accessing metadata from the git dvcs",
		url        = {http://www.ctan.org/pkg/gitinfo2},
		urldate    = {2016-06-27},
	}
\end{filecontents}
\usepackage[%
	backend=biber,
	sortlocale=de_DE,
	style=authoryear,
	bibencoding=UTF8,
	block=space,
	autocite=inline,
	language=ngerman,
]{biblatex}
\addglobalbib{gitfile-info.bib}
\renewcommand*{\mkbibnamefamily}{\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}}
\newcommand{\refMacro}[1]{Makro \texttt{\textbackslash#1}, S.\,\pageref{#1}}
\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{orange},          
  morekeywords={
		minisec, subsection, glqq, grqq, euro, href,
		gfiGetAuthorName, gfiGetAuthorMail, gfiGetCommit, gfiGetCommitAbr,
		gfiGetDate, gfiGetMin, gfiGetHour, gfiGetDay, gfiGetMonth,
		gfiGetYear, gfiInfo,
  },
	literate=%
	{Ö}{{\"O}}1
	{Ä}{{\"A}}1
	{Ü}{{\"U}}1
	{ß}{\ss}2
	{ü}{{\"u}}1
	{ä}{{\"a}}1
	{ö}{{\"o}}1
	{»}{{\frqq}}4
	{«}{{\flqq}}4	
	{~}{$\sim$}1	
}
\newcommand{\wM}[1]{\texttt{\textbackslash#1}}

\xspaceaddexceptions{\guillemotright,\guillemotleft}

\usepackage{gitfile-info}
\usepackage{scrpage2}
\pagestyle{scrheadings}
\ifoot{Commit: \gfiGetCommitAbr}
\ofoot{\thepage}
\ihead{\gfiGetAuthorName}
\ohead{Stand: \gfiGetDate}

\CheckSum{122}

\makeatletter
\newcommand{\@subtitleA}{}
\newcommand{\@subtitleB}{}
\newcommand{\subtitle}[2]{%
	\renewcommand{\@subtitleA}{#1}
	\renewcommand{\@subtitleB}{#2}
}
\renewcommand\@maketitle{%
\hfil
\begin{minipage}{0.8\textwidth}
	\centering
	\vskip 2em
	\let\footnote\thanks 
	{\LARGE \@title \par }
	\vskip 1.5em
	{\Large \@subtitleA \par }
	\vskip 1.5em
	{\Large \@subtitleB \par }
	\vskip 1.5em
	{\large \@author \par}
\end{minipage}
\hfil
\vskip 1em \par
}
\makeatother

\begin{document}
\DocInput{gitfile-info.dtx}
\end{document}
%</driver>
%\fi
%	\title{\textbf{Gitfile-Info}}
%	\subtitle{%
%		\LaTeX-Paket zum Auslesen von git Ver"-sions"-in"-for"-ma"-tion"-en für eine
%		Datei
%	}{%
%	 \LaTeX-package for reading git commit info for a specific file%
%	}
%	\author{Andr\'e Hilbig\\	\href{mailto:mail@andrehilbig.de}{mail@andrehilbig.de} --
%		\href{http://www.andrehilbig.de/u/gfi}{andrehilbig.de/u/gfi}}
%	\date{\gfiGetDay.\gfiGetMonth.\gfiGetYear}
%	\maketitle
%
%	\begin{abstract}
%		 \foreignlanguage{english}{
%			 If you are using git to control versions of \LaTeX-files, you may want to show yourself or
%			 other users or devs the current version of the file, information about the author and last
%			 edited date. All packages for git known make that kind of information available for the whole
%			 repository. But sometimes you have a lot of files within the same repository in different
%			 versions, from different authors etc. Perhaps you also split up a big project in small files
%			 and want to show within the document who had edited what. This package gives you the
%			 opportunity to do so.
%			}
%
%			Wenn Versionen von \LaTeX-Dateien mit git kontrolliert werden, dann kommt es vor, dass für
%			einen selbst, andere Nutzern oder Entwickler der aktuelle Entwicklungsstand der Datei,
%			Hinweise zum Autor und dem Datum der letzten Bearbeitung im PDF gezeigt werden sollen. Mir
%			bekannte Pakete können zwar den Stand des Repositories auslesen, jedoch nicht für eine
%			bestimmte Datei unterscheiden. Allerdings wird manchmal mit vielen Dateien in einem Repository
%			gearbeitet, die jeweils in verschiedenen Versionen vorliegen. Möglicherweise soll auch ein
%			großes Projekt in mehrere \TeX-Dateien aufgeteilt werden. Dann soll dennoch für jede einzelne
%			Datei die Versionsinfo angezeigt werden können. Dieses Paket soll diese Funktionalität
%			liefern.
%	\end{abstract}
%	\begin{multicols}{2}
%	 \tableofcontents
%	\end{multicols}
%
%	\section{Änderungen}
%			\begin{description}
%				\item[v0.1] Intialisierung und erste Veröffentlichung
%				\item[v0.2] Dokumentation auf CTAN inkludiert
%				\item[v0.3] Pfad der Scripte in texlive in der Dokumentation aktualisiert -- Pythonscripte
%					erzwingen Py3 und geben Fehler bei falscher Lokalisierung aus.
%			\end{description}
%
%	\section{Installation}
%		\subsection{Systemanforderungen}
%			Um die Informationen über einzelne Dateien aus dem git auszulesen, müssen entsprechende
%			Scripte bzw. Hooks innerhalb des Repositories platziert werden. Damit eine möglichst breite
%			Nutzbarkeit möglich ist, habe ich mich dazu entschieden mit Python und der
%			gitpython-Bibliothek zu arbeiten.
%
%			\begin{itemize}
%				\item Python>=3
%				\item gitpython: \fullcite{gitpython}
%
%					(kann über \verb|pip| installiert werden)
%			\end{itemize}
%
%			\textbf{Hinweis:} Die Scripte werden in erster Linie für Unix-basierte Betriebssysteme
%			geschrieben. Support für andere Systeme kann und möchte ich nicht leisten.
%
%		\subsection{Automatische Installation}
%			Das Paket ist über \verb|CTAN| verfügbar und kann so mit dem \verb|tlmgr| bzw. der
%			Paketverwaltung des Betriebssystems\footnote{Leider halten viele Distributionen ihre
%				\LaTeX-Installationen nicht aktuell. Daher wird empfohlen die direkten Quellen, etwa von
%				|texlive|, zu verwenden.} abgerufen	werden.
%
%		\subsection{Manuelle Installation}
%			Falls eine automatisierte Installation nicht möglich ist, können die Pakete auch manuell
%			installiert werden. Es wird jedoch empfohlen, eine aktuelle Distribution zu verwenden, etwa
%			\verb|texlive2016|. Für Versionen davor kann keine Kompatibilität gewährleistet werden. Zur
%			Installation werden die Dateien \verb|gitfile-info.ins| und \verb|gitfile-info.dtx| benötigt.
%		
%			\begin{itemize}
%				\item Erzeugung der Paketdateien und Dokumentation
%					
%					\begin{lstlisting}[gobble=12,numbers=none,language=bash,%
%						linewidth=0.7\textwidth,resetmargins=false]
%						latex gitfile-info.ins
%						latexmk -pdf gitfile-info.dtx
%					\end{lstlisting}
%				\item Die erzeugte Paketdatei (*.sty) muss in einem für \TeX\ lesbarem Verzeichnis platziert
%					werden. Für eine lokale Installation bietet sich dafür 
%					
%					\verb|~/texmf/tex/latex/gitfile-info/|
%				 
%					an.
%				\item Außerdem werden die drei Python-Scripte 
%					
%					\verb|gfi-run.py|, \verb|post-commit.py| und \verb|post-merge.py| 
%					
%					erstellt. Diese Dateien müssen im Repository platziert werden
%					(vgl. \prettyref{sec:installation-git}).
%			\end{itemize}
%
%		\subsection{Einrichtung des Repositories}\label{sec:installation-git}
%			Die beiden Scripte \verb|post-commit.py| und \verb|post-merge.py| müssen innerhalb des Repositories im
%			Verzeichnis \verb|.git/hooks| als ausführbare Dateien unter den Namen \verb|post-commit| bzw.
%			\verb|post-merge| platziert werden.
%			\begin{description}
%				\item[\verb|post-commit|] wird bei jedem Commit ausgeführt (nachdem der Commit vollständig
%					beendet ist) und schreibt für die veränderten \TeX-Dateien Änderungen in eine Hilfsdatei.
%				\item[\verb|post-merge|] wird nach jedem merge (erfolgreich und nicht erfolgreich --
%					explizit auch nach einem pull) ausgeführt, um Veränderungen in die Hilfsdatei einzutragen.
%			\end{description}
%
%			Außerdem sollte das Script \verb|gfi-run.py| möglichst für jeden Nutzer im Repository ausführbar
%			platziert werden. Wird das Script ohne Parameter ausgeführt, liest es sämtliche unter
%			Versionsverwaltung stehende Dateien aus und erstellt die passenden Hilfsdateien. Wird dem
%			Script eine \TeX-Datei (inkl. Endung) übergeben, wird die Hilfsdatei für diese spezielle Datei
%			neu erstellt.
%			\begin{lstlisting}[gobble=10,numbers=none,language=bash,%
%				linewidth=0.7\textwidth,resetmargins=false]
%					# alle *.tex-Dateien aktualisieren
%					python gfi-run.py
%					# eine spezielle *.tex-Datei aktualisieren
%					python gfi-run.py datei.tex
%			\end{lstlisting}
%
%			Die Scripte sollten in einer Standard \texttt{texlive}"~Installation unter dem Pfad
%			\verb|…/texmf-dist/doc/support/gitfile-info/| gefunden werden können. Bei einer manuellen
%			Installation sollten die Scripte mit erstellt worden sein.
%
%			\textbf{Hinweis:} Die drei Dateien sollten Nutzern zur Verfügung gestellt werden.
%			Typischerweise sind sie nach einem Clone nicht im Baum enthalten. Jeder Nutzer muss sich die
%			Hooks selbstständig einrichten -- außer es werden entsprechende Konfigurationen festgelegt.
%
%			Außerdem muss in der \verb|*.gitignore| der Filter \verb|*.gfi| festgelegt werden, da die
%			Hilfsdateien in \textbf {keinem} Fall unter Versionsverwaltung stehen dürfen. Daher muss ein
%			Nutzer nach einem \textit{frischen} Clone das Script \verb|gfi-run.py| aufrufen, um alle
%			Hilfsdateien lokal zu erstellen.
%
%	\section{Funktionsweise}
%		\subsection{Vorüberlegungen}
%			Zunächst stand die Überlegung im Raum, Meta-Daten ähnlich wie beim Paket \verb|svninfo|
%			\autocite[vgl.][]{svninfo} direkt in die betreffenden \TeX-Dateien einzutragen. Dadurch wird
%			jedoch der Arbeitsstand verändert und der eingetragene Commit ist nicht mehr aktuell. Es
%			müsste ein erneuter Commit erfolgen usw. Hier gäbe es die Möglichkeit, automatisierte Commits
%			zu erstellen. Diese würden jedoch das Repository aufblähen.
%
%			Daher entschied ich mich dafür, die passenden Meta-Daten in eine Hilfsdatei (\verb|*.gfi|)
%			einzutragen. Hier können per simplem \LaTeX-Befehl Metadaten eingegeben werden. Das bereits
%			bestehende Paket gitinfo2 \autocite[vgl.][]{gitinfo2} konnte nicht benutzt werden, da es das
%			gesamte Repository ausliest und nicht zwischen einzelnen Dateien unterscheidet.
%
%		\subsection{Umsetzung}
%			Bei jedem Commit oder Pull gehen die Scripte alle geänderten \TeX-Dateien durch und
%			aktualisieren die entsprechenden Hilfsdateien. Hier werden \textbf{nur} Dateien mit der Endung
%			\verb|*.tex| berücksichtigt! Bei Problemen kann das Script \verb|gfi-run.py| per Hand aufgerufen
%			werden, um eine Aktualisierung zu erzwingen (vgl. \prettyref{sec:installation-git}).
%
%
%	\section{Nutzung des Pakets}
%		Alle Makros geben immer die Versionsinformationen für die \textit{aktuelle} Datei zurück, sofern
%		diese geeignet geladen wurde (vgl. \prettyref{sec:nutzung-include}). Das Paket wird dazu in der
%		Präambel des Dokumentes geladen.
%		\begin{lstlisting}[gobble=8,numbers=none,%
%			linewidth=0.7\textwidth,resetmargins=false]
%				\usepackage{gitfile-info}
%		\end{lstlisting}
%		Weitere Optionen müssen nicht angegeben werden. Sofern notwendige Hilfsdateien mit der Endung
%		\verb|*.gfi| noch nicht vorhanden sind, werden alle Makros mit Standardwerten belegt und eine
%		Warnung ausgegeben.
%
%		\subsection{Auslesen der Metadaten}
%		\DescribeMacro{\gfiGet}
%		Über die \verb|\gfiGet*|-Makros können die Metadaten aus dem Repository ausgelesen werden.
%
%		\begin{description}
%			\item[\wM{gfiGetDay}] gibt den Tag der letzten Änderung als zweistellige Ziffer zurück.
%			\item[\wM{gfiGetMonth}] gibt den Monat der letzten Änderung als zweistellige Ziffer zurück.
%			\item[\wM{gfiGetYear}] gibt das Jahr der letzten Änderung als zweistellige Ziffer zurück.
%			\item[\wM{gfiGetHour}] gibt die Stunde	der letzten Änderung als zweistellige Ziffer zurück.
%			\item[\wM{gfiGetMin}] gibt die Minute der letzten Änderung als zweistellige Ziffer
%				zurück.
%			\item[\wM{gfiGetDate}] gibt das volle Datum der letzten Änderung mit Uhrzeit im Format
%				\verb|dd. Monat yyyy HH:MM| zurück\footnote{Das Format wird durch die Scripte vorgegeben und muss in
%				diesen ggfs. angepasst werden, sofern eine Lokalisierung gewünscht ist (vgl.
%				\prettyref{sec:implementierung-scripte})}
%			\item[\wM{gfiGetAuthorName}] gibt den Namen des Autors der letzten Änderung zurück.
%			\item[\wM{gfiGetAuthorMail}] gibt die E-Mailadresse des Autors der letzten Änderung zurück.
%			\item[\wM{gfiGetCommit}] gibt den Hash des letzten Commits zurück.
%			\item[\wM{gfiGetCommitAbr}] gibt die Kurzform des letzten Commits zurück.
%		\end{description}
%
%		Ergänzend sei auf das Paket datenumber \autocite[vgl.][]{datenumber} verwiesen. Damit ist es
%		möglich obige Makros für Tag, Monat und Jahr zwischen lokalisierten Monatsbezeichnungen usw. zu
%		konvertieren. 
%
%		\subsection{Versionsinfo}
%		\DescribeMacro{\gfiInfo}
%		Sofern eine kleine Zusammenfassung der aktuellen Datei gezeigt werden soll, kann dazu das Makro
%
%		|\gfiInfo|\oarg{Hashlänge}\oarg{Datumsformat}\oarg{Autorformat}\oarg{tcolorbox}\\
%		benutzt werden. Sofern alle optionalen Argumente leer gelassen werden, wird der lange Hash, das
%		Standard \wM{gfiGetDate} und der Name des Autors als Hyperlink auf die E-Mailadresse in einer
%		|tcolorbox| mit dem Namen |gfiInfoBox| ausgegeben.
%
%		\gfiInfo
%
%		\begin{description}
%			\item[Hashlänge] kann durch Angabe von |abr| als verkürzter Hash ausgegeben werden. Standard:
%				lang.
%			\item[Datumsformat, Autorformat] können jeweils beliebige \TeX-Befehle enthalten. Standard:
%				langes Datum und Name als Hyperlink.
%			\item[tcolorbox] kann einer beliebigen über |\newtcolorbox{}| eingeführten tcolorbox
%				entsprechen. Standard: |gfiInfoBox|.
%		\end{description}
%
%		\DescribeMacro{gfiInfoBox}
%		Durch Verwendung der definierten Box \verb|gfiInfoBox| können auch beliebige andere
%		Zusammenstellungen erstellt werden.
%
%		\begin{lstlisting}[gobble=6,]
%			\begin{gfiInfoBox}
%				\vspace{1mm}
%				Die letzte Änderung wurde durch den Autor \gfiGetAuthorName\
%				(\href{mailto:\gfiGetAuthorMail}{\gfiGetAuthorMail}) am 
%				\gfiGetDay.\gfiGetMonth.\gfiGetYear\ um
%				\gfiGetHour:\gfiGetMin\,Uhr commited.	Die letzte Änderung 
%				hat den Commit \gfiGetCommitAbr.
%				\vspace{1mm}
%			\end{gfiInfoBox}
%		\end{lstlisting}
%
%		\begin{gfiInfoBox}
%			\vspace{1mm}
%			Die letzte Änderung wurde durch den Autor \gfiGetAuthorName\
%			(\href{mailto:\gfiGetAuthorMail}{\gfiGetAuthorMail}) am \gfiGetDay.\gfiGetMonth.\gfiGetYear\ um
%			\gfiGetHour:\gfiGetMin\,Uhr commited.	Die letzte Änderung hat den Commit \gfiGetCommitAbr.
%			\vspace{1mm}
%		\end{gfiInfoBox}
%
%		\subsection{Laden weiterer \TeX-Dateien}\label{sec:nutzung-include}
%		Ähnlich wie im Paket \verb|svninfo| \autocite[vgl.][]{svninfo} soll auch die Aufsplittung eines
%		größeren Projekts in mehrere Teildateien mit den entsprechenden Versionen der einzelnen Dateien
%		auslesbar sein. Dafür müssen diese Dateien ebenfalls die Endung \verb|*.tex| haben, um von den
%		Scripten erkannt zu werden.
%
%		\DescribeMacro{gfiInclude}
%		\DescribeMacro{gfiInput}
%		Im Hauptdokument werden die Metadaten automatisch beim Beginn geladen. Sofern eine weitere Datei
%		per \wM{include} oder \wM{input} geladen werden soll, müssen dafür die Befehle
%
%		|\gfiInclude|\marg{Datei} bzw. |\gfiInput|\marg{Datei}\\
%		genutzt werden. Die Endung der Datei sollte dabei \textbf{nicht} mit angegeben werden. Intern
%		werden die jeweiligen Befehle zum Laden einer weiteren Datei entsprechend genutzt. Außerdem wird
%		die zugehörige Hilfsdatei eingebunden, um die notwendigen Metadaten zu erhalten. Nachdem die
%		inkludierte Datei vollständig bearbeitet wurde, werden die Metadaten der vorherigen bzw. dann
%		aktuellen Datei geladen. Es ist auch möglich, beliebige Verschachtelungen vorzunehmen.
%
%
%
%	\section{Implementierung}
%		\subsection{Paket}
%			Das Paket lädt automatisch die zugehörige Hilfsdatei eines Hauptdokuments über den
%			entsprechenden \wM{jobname}. Der Nutzer musst hierfür keine Anpassung vornehmen. Sollten
%			weitere Dokumente eingebunden werden, müssen die bereitgestellten Befehle genutzt werden,
%			sofern die zugehörigen Versioninformationen geladen werden sollen (vgl.
%			\prettyref{sec:nutzung-include}). Die Hilfsdatei trägt den selben Namen, wie die zugehörige
%			\TeX-Datei, und enthält passende Aufrufe der \wM{gfiSet*}-Makros.
%
%			\DescribeMacro{\gfiSetDate}
%			|\gfiSetDate|\marg{Tag}\marg{Monat}\marg{Jahr}\\
%			\hspace*{5em}\marg{Stunde}\marg{Minute}\marg{Lokalisierte Langfassung}\\
%			Tag, Monat, Stunde und Minute sind jeweils als zweistellige Ziffern einzulesen. Das Jahr wird
%			als vierstellige Ziffer eingelesen und in der Langassung kann beliebiger Text stehen, der
%			einer durch die Scripte lokalisierten Version entspricht. Dadurch werden die
%			\wM{gfiGet*}-Makros definiert. \wM{gfiGetDate} entspricht der Langfassung.
%
%			\DescribeMacro{\gfiSetAuthor}
%			|\gfiSetAuthor|\marg{Name}\marg{E-Mail}\\
%			Name und E-Mail sollten die zugehörigen Daten enthalten und werden mit den \wM{gfiGet*}-Makros
%			verknüpft.
%
%			\DescribeMacro{\gfiSetCommit}
%			|\gfiSetCommit|\marg{Hash}\marg{Hash-Abr}\\
%			Die volle Fassung des Commits wird im Hash, die kurze Version im Hash-Abr eingegeben und
%			entsprechend mit \wM{gfiGet*} verknüpft.
%
%		\subsection{Scripte}\label{sec:implementierung-scripte}
%			Die Scripte sind auf deutsche Monatsbezeichnungen eingestellt. Sofern hier eine andere
%			Lokalisierung gewünscht wird, muss in \textit{allen} Scripten der entsprechende Eintrag in der
%			Präambel geändert werden! Prinzipiell reicht es aus im ersten Block zu ändern, da bei einer
%			individuellen Anpassungen Fehler nicht auftreten sollten.
%			
%			\begin{lstlisting}[gobble=8,numbers=none,language=python,%
%					linewidth=0.7\textwidth,resetmargins=false]
%				try:
%						locale.setlocale(locale.LC_ALL, 'de_DE.utf8')
%				except:
%						try:
%								locale.setlocale(locale.LC_ALL, 'de_DE')
%			\end{lstlisting}
%					
%
%			\subsubsection{gfi-run.py}
%				Das \verb|gfi-run.py| kann sowohl zur Initialisierung als auch zur erzwungenen Aktualisierung
%				aller \TeX-Dateien benutzt werden.
%				\begin{lstlisting}[gobble=12,numbers=none,language=bash,%
%					linewidth=0.7\textwidth,resetmargins=false]
%						# alle *.tex-Dateien aktualisieren
%						python gfi-run.py
%						# eine spezielle *.tex-Datei aktualisieren
%						python gfi-run.py datei.tex
%				\end{lstlisting}
%
%				Das Script sucht dabei mithilfe von \verb|git ls-files| nach allen unter Versionsverwaltung
%				stehenden Dateien und erstellt (überschreibend) aufgrund von \verb|git log| für jede Datei
%				einzeln die passende Hilfsdatei mit den Metadaten. Wird eine Datei übergeben, so wird nicht
%				geprüft, ob diese unter Verwaltung steht und eine Hilfsdatei (im Zweifel leer) erstellt.
%
%				\lstinputlisting[language=python,title=Quelltext von gfi-run.py]{gfi-run.py}
%
%			\subsubsection{post-commit.py}
%				Der \verb|post-commit|-Hook von \verb|git| wird nach jedem Commit, der erfolgreich
%				ausgeführt wurde, automatisch ausgeführt. Der Hook liest aus, welche Dateien sich verändert
%				haben und ändert für die passenden \TeX-Dateien die Hilfsdateien mit den neuen Metadaten.
%				Das Script sollte im Verzeichnis \verb|.git/hooks| ausführbar platziert werden.
%
%				\lstinputlisting[language=python,title=Quelltext von post-commit.py]{post-commit.py}
%			
%			\subsubsection{post-merge.py}
%				Der \verb|post-merge|-Hook von \verb|git| wird nach jedem Merge ausgeführt. Er wird auch bei
%				einem nicht erfolgreichen Merge aufgerufen. Explizit bedeutet dies auch, dass nach jedem
%				Pull das Script ausgeführt wird. Der Hook liest aus, welche Dateien sich verändert
%				haben und ändert für die passenden \TeX-Dateien die Hilfsdateien mit den neuen Metadaten.
%				Das Script sollte im Verzeichnis \verb|.git/hooks| ausführbar platziert werden.
%
%				\lstinputlisting[language=python,title=Quelltext von post-merge.py]{post-merge.py}
%
%	\addcontentsline{toc}{section}{Literatur}
%	\printbibliography[title=Weiterführende Quellen]
%
%
%\StopEventually{}
%\section{Code}
%\iffalse
%    \begin{macrocode}
%<*gitfile-info.sty>
%    \end{macrocode}
%\fi
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{gitfile-info}
    [2016/06/30 v0.2 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}
%    \end{macrocode}
%
% \begin{macro}{\gfiGetDay}
%    \begin{macrocode}
\providecommand{\gfiGetDay}{gfi day}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\gfiGetMonth}
%    \begin{macrocode}
\providecommand{\gfiGetMonth}{gfi month}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\gfiGetYear}
%    \begin{macrocode}
\providecommand{\gfiGetYear}{gfi year}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\gfiGetHour}
%    \begin{macrocode}
\providecommand{\gfiGetHour}{gfi hour}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\gfiGetMin}
%    \begin{macrocode}
\providecommand{\gfiGetMin}{gfi min}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\gfiGetAuthorName}
%    \begin{macrocode}
\providecommand{\gfiGetAuthorName}{gfi author name}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\gfiGetAuthorMail}
%    \begin{macrocode}
\providecommand{\gfiGetAuthorMail}{gfi author email}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\gfiGetDate}
%    \begin{macrocode}
\providecommand{\gfiGetDate}{gfi date}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\gfiGetCommit}
%    \begin{macrocode}
\providecommand{\gfiGetCommit}{gfi commit}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\gfiGetCommitAbr}
%    \begin{macrocode}
\providecommand{\gfiGetCommitAbr}{gfi commit short}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\gfiSetDate}
%    \begin{macrocode}
\providecommand{\gfiSetDate}[6]{%
	\renewcommand{\gfiGetDay}{#1}
	\renewcommand{\gfiGetMonth}{#2}
	\renewcommand{\gfiGetYear}{#3}
	\renewcommand{\gfiGetHour}{#4}
	\renewcommand{\gfiGetMin}{#5}
	\renewcommand{\gfiGetDate}{#6}
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\gfiSetAuthor}
%    \begin{macrocode}
\providecommand{\gfiSetAuthor}[2]{%
	\renewcommand{\gfiGetAuthorName}{#1}
	\renewcommand{\gfiGetAuthorMail}{#2}
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\gfiSetCommit}
%    \begin{macrocode}
\providecommand{\gfiSetCommit}[2]{%
	\renewcommand{\gfiGetCommit}{#1}
	\renewcommand{\gfiGetCommitAbr}{#2}
}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
\colorlet{colback}{yellow!20!black}
\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=colback!80!black] ([yshift=3mm]interior.south east)--++(-0.4,-0.1)--++(0.1,-0.2);
		\path[draw=black!75!white,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}
		\vspace{1mm}
		\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}
		\vspace{1mm}
	\end{#4}
}
%    \end{macrocode}
%
% \begin{macro}{\gfiCurrentConfig}
%    \begin{macrocode}
\providecommand{\gfiCurrentConfig}{none}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\gfiInitJob}
%    \begin{macrocode}
\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?}
	}
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\gfiInitInc}
%    \begin{macrocode}
\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?}
	}
}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
\AtBeginDocument{%
	\gfiInitJob
}
%    \end{macrocode}
%
% \begin{macro}{\gfiInput}
%    \begin{macrocode}
\providecommand{\gfiInput}[1]{%
	\gfiInitInc{#1}
	\input{#1}
	\gfiInitInc{\currfiledir\currfilebase}
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\gfiInclude}
%    \begin{macrocode}
\providecommand{\gfiInclude}[1]{%
	\gfiInitInc{#1}
	\include{#1}
	\gfiInitInc{\currfiledir\currfilebase}
}
%    \end{macrocode}
% \end{macro}
%
%\iffalse
%    \begin{macrocode}
%</gitfile-info.sty>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*gfi-run.py>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# -*- mode:python -*-
import os
import sys
import time
import codecs
from git import Repo
import locale
# Locales for date set up to de_DE
# Please edit to you needs
try:
    locale.setlocale(locale.LC_ALL, 'de_DE.utf8')
except:
    try:
        locale.setlocale(locale.LC_ALL, 'de_DE')
    except:
        print ("Fehler: bitte prüfen Sie das Ergebnis von 'locale -d' und fügen es in das Script ein.")

# set up the git repo
# path is the current working directory
pathrepo = os.getcwd()
repo = Repo(pathrepo)
assert not repo.bare
git = repo.git
headcommit = repo.head.commit
index = repo.index

# check for specific file (else) or
# every tex file within the git
if len(sys.argv) <= 1:
    # get all the files within the git
    commFiles = git.ls_files(full_name=True).split("\n")

    # iterate through all files and read date/author/commit and
    # write in the help file
    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.localtime(rawdate)),
                    time.strftime("%d", time.localtime(rawdate)),
                    time.strftime("%m", time.localtime(rawdate)),
                    time.strftime("%Y", time.localtime(rawdate)),
                    time.strftime("%H", time.localtime(rawdate)),
                    time.strftime("%M", time.localtime(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] + "}")
            f.close
else:
    # get the specific file, read date/author/commit and
    # write the help file
    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.localtime(rawdate)),
            time.strftime("%d", time.localtime(rawdate)),
            time.strftime("%m", time.localtime(rawdate)),
            time.strftime("%Y", time.localtime(rawdate)),
            time.strftime("%H", time.localtime(rawdate)),
            time.strftime("%M", time.localtime(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] + "}")
    f.close
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</gfi-run.py>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*post-commit.py>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# -*- mode:python -*-
import os
import time
import codecs
from git import Repo
import locale
# Locales for date set up to de_DE
# Please edit to you needs
try:
    locale.setlocale(locale.LC_ALL, 'de_DE.utf8')
except:
    try:
        locale.setlocale(locale.LC_ALL, 'de_DE')
    except:
        print ("Fehler: bitte prüfen Sie das Ergebnis von 'locale -d' und fügen es in das Script ein.")

# set up the git repo
# path is the current working directory
pathrepo = os.getcwd()
repo = Repo(pathrepo)
assert not repo.bare
git = repo.git
headcommit = repo.head.commit
index = repo.index

# get the commited/changed files and date/author/commit
commFiles = git.diff_tree('-r', 'HEAD', no_commit_id=True,
                          name_only=True).split("\n")
date = [time.strftime("%d. %B %Y %H:%M",
                      time.localtime(headcommit.authored_date)),
        time.strftime("%d", time.localtime(headcommit.authored_date)),
        time.strftime("%m", time.localtime(headcommit.authored_date)),
        time.strftime("%Y", time.localtime(headcommit.authored_date)),
        time.strftime("%H", time.localtime(headcommit.authored_date)),
        time.strftime("%M", time.localtime(headcommit.authored_date))]
author = [headcommit.author.name, headcommit.author.email]
commit = [headcommit.hexsha, headcommit.hexsha[:6]]

# iterate through all files and write the gfi help-files
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] + "}")
        f.close
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</post-commit.py>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*post-merge.py>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# -*- mode:python -*-
import os
import time
import codecs
from git import Repo
import locale
# Locales for date set up to de_DE
# Please edit to you needs
try:
    locale.setlocale(locale.LC_ALL, 'de_DE.utf8')
except:
    try:
        locale.setlocale(locale.LC_ALL, 'de_DE')
    except:
        print ("Fehler: bitte prüfen Sie das Ergebnis von 'locale -d' und fügen es in das Script ein.")

# set up the git repo
# path is the current working directory
pathrepo = os.getcwd()
repo = Repo(pathrepo)
assert not repo.bare
git = repo.git
headcommit = repo.head.commit
index = repo.index

# get the commited/changed files and date/author/commit
commFiles = git.diff_tree('-r', 'ORIG_HEAD', 'HEAD',
                          no_commit_id=True, name_only=True).split("\n")

# iterate through all files and write the gfi help-files
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.localtime(rawdate)),
                time.strftime("%d", time.localtime(rawdate)),
                time.strftime("%m", time.localtime(rawdate)),
                time.strftime("%Y", time.localtime(rawdate)),
                time.strftime("%H", time.localtime(rawdate)),
                time.strftime("%M", time.localtime(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] + "}")
        f.close
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</post-merge.py>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*gitfile-info.gfi>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
% gitfile-info control file
\gfiSetDate{09}{04}{2019}{19}{40}{09. April 2019 19:40}
\gfiSetAuthor{André Hilbig}{mail@andrehilbig.de}
\gfiSetCommit{ac5f4546b3f9533f287c2ce27843a92e2dfa4a68}{ac5f45}%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</gitfile-info.gfi>
%    \end{macrocode}
%\fi
%\Finale
\endinput