From 1e9b5e4a3d19af7014ac743b5226a9a9ce419fe5 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Tue, 28 Jun 2016 21:03:22 +0000 Subject: gitfile-info (28jun16) git-svn-id: svn://tug.org/texlive/trunk@41562 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/support/gitfile-info/README | 52 + .../texmf-dist/doc/support/gitfile-info/gfi-run.py | 75 ++ .../doc/support/gitfile-info/gitfile-info.gfi | 3 + .../doc/support/gitfile-info/post-commit.py | 45 + .../doc/support/gitfile-info/post-merge.py | 47 + .../source/support/gitfile-info/gitfile-info.dtx | 1026 ++++++++++++++++++++ .../source/support/gitfile-info/gitfile-info.ins | 35 + .../tex/latex/gitfile-info/gitfile-info.sty | 144 +++ Master/tlpkg/bin/tlpkg-ctan-check | 3 +- Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc | 1 + Master/tlpkg/tlpsrc/gitfile-info.tlpsrc | 0 11 files changed, 1430 insertions(+), 1 deletion(-) create mode 100644 Master/texmf-dist/doc/support/gitfile-info/README create mode 100644 Master/texmf-dist/doc/support/gitfile-info/gfi-run.py create mode 100644 Master/texmf-dist/doc/support/gitfile-info/gitfile-info.gfi create mode 100644 Master/texmf-dist/doc/support/gitfile-info/post-commit.py create mode 100644 Master/texmf-dist/doc/support/gitfile-info/post-merge.py create mode 100644 Master/texmf-dist/source/support/gitfile-info/gitfile-info.dtx create mode 100644 Master/texmf-dist/source/support/gitfile-info/gitfile-info.ins create mode 100644 Master/texmf-dist/tex/latex/gitfile-info/gitfile-info.sty create mode 100644 Master/tlpkg/tlpsrc/gitfile-info.tlpsrc (limited to 'Master') diff --git a/Master/texmf-dist/doc/support/gitfile-info/README b/Master/texmf-dist/doc/support/gitfile-info/README new file mode 100644 index 00000000000..af1aea72c32 --- /dev/null +++ b/Master/texmf-dist/doc/support/gitfile-info/README @@ -0,0 +1,52 @@ ++ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -+ +| | +| PACKAGE `gitfile-info' | +| | + 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. ++ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -+ + Version: 0.1 + Last Change: 2016-06-27 + Current Maintainer: André Hilbig + mail@andrehilbig.de ++ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -+ + + This work may be distributed and/or modified under the + conditions of the LaTeX Project Public License, either version 1.3 + of this license of (at your option) any later version. + The latest version of this license is in + http://www.latex-project.org/lppl.txt + and version 1.3 or later is part of all distributions of LaTeX + version 2005/12/01 or later. + + This work has the LPPL maintenance status `maintained'. + + This work consists of the files gitfile-info.sty, gfi-run, post-commit, post-merge. +| | ++ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -+ +| | +| Installation | +| | + Getting the files: + latex gitfile-info.ins + + Getting the documentation: + latexmk -pdf gitfile-info.dtx + + Copy the following file into a TeX-readable directory: + gitfile-info.sty + + Copy the hooks into .git/hooks: + post-commit + post-merge + + Copy the init-script into a executable directory, maybe within the git-repo to post it to the + other users: + gfi-run +| | ++ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -+ diff --git a/Master/texmf-dist/doc/support/gitfile-info/gfi-run.py b/Master/texmf-dist/doc/support/gitfile-info/gfi-run.py new file mode 100644 index 00000000000..93806bf53ba --- /dev/null +++ b/Master/texmf-dist/doc/support/gitfile-info/gfi-run.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python +# -*- 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 +locale.setlocale(locale.LC_ALL, 'de_DE') + +# 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 diff --git a/Master/texmf-dist/doc/support/gitfile-info/gitfile-info.gfi b/Master/texmf-dist/doc/support/gitfile-info/gitfile-info.gfi new file mode 100644 index 00000000000..31f815e9fa1 --- /dev/null +++ b/Master/texmf-dist/doc/support/gitfile-info/gitfile-info.gfi @@ -0,0 +1,3 @@ +\gfiSetDate{27}{06}{2016}{22}{39}{27. Juni 2016 22:39} +\gfiSetAuthor{André Hilbig}{mail@andrehilbig.de} +\gfiSetCommit{bad8f21c471b20eaba584a728b5809e9126370e3}{bad8f2}% \end{macrocode} diff --git a/Master/texmf-dist/doc/support/gitfile-info/post-commit.py b/Master/texmf-dist/doc/support/gitfile-info/post-commit.py new file mode 100644 index 00000000000..4f9a7aa2dd6 --- /dev/null +++ b/Master/texmf-dist/doc/support/gitfile-info/post-commit.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python +# -*- 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 +locale.setlocale(locale.LC_ALL, 'de_DE') + +# 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 diff --git a/Master/texmf-dist/doc/support/gitfile-info/post-merge.py b/Master/texmf-dist/doc/support/gitfile-info/post-merge.py new file mode 100644 index 00000000000..0988c7ed913 --- /dev/null +++ b/Master/texmf-dist/doc/support/gitfile-info/post-merge.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python +# -*- 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 +locale.setlocale(locale.LC_ALL, 'de_DE') + +# 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 diff --git a/Master/texmf-dist/source/support/gitfile-info/gitfile-info.dtx b/Master/texmf-dist/source/support/gitfile-info/gitfile-info.dtx new file mode 100644 index 00000000000..8f60f48e386 --- /dev/null +++ b/Master/texmf-dist/source/support/gitfile-info/gitfile-info.dtx @@ -0,0 +1,1026 @@ +%\iffalse +% gitfile-info.dtx generated using makedtx version 0.94b (c) Nicola Talbot +% Command line args: +% -author "André Hilbig, mail@andrehilbig.de" +% -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 "2016-06-27:22:50:57 -- Version 0.1" +% -codetitle "Code" +% -macrocode "gfi-run.py" +% -macrocode "post-commit.py" +% -macrocode "post-merge.py" +% -macrocode "gitfile-info.gfi" +% -setambles "gitfile-info.gfi=>\nopreamble\nopostamble" +% -setambles "gfi-run.py=>\nopreamble\nopostamble" +% -setambles "post-commit.py=>\nopreamble\nopostamble" +% -setambles "post-merge.py=>\nopreamble\nopostamble" +% -comment "gitfile-info.gfi" +% -comment "gfi-run.py" +% -comment "post-commit.py" +% -comment "post-merge.py" +% gitfile-info +% Created on 2016-06-27:22:50:57 -- Version 0.1/6/27 22:50 +%\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 \~} +% +%\fi +% \iffalse +% Doc-Source file to use with LaTeX2e +% Copyright (C) 2016-06-27:22:50:57 -- Version 0.1 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*{\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}} +\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{121} + +\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} +% +%\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 +% \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/latex/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! +% +% \begin{lstlisting}[gobble=8,numbers=none,language=python,% +% linewidth=0.7\textwidth,resetmargins=false] +% 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/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} +% \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} +\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} + \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} +% +% \end{macrocode} +%\fi +%\iffalse +% \begin{macrocode} +%<*gfi-run.py> +% \end{macrocode} +%\fi +%\iffalse +% \begin{macrocode} +#!/usr/bin/env python +# -*- 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 +locale.setlocale(locale.LC_ALL, 'de_DE') + +# 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} +% +% \end{macrocode} +%\fi +%\iffalse +% \begin{macrocode} +%<*post-commit.py> +% \end{macrocode} +%\fi +%\iffalse +% \begin{macrocode} +#!/usr/bin/env python +# -*- 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 +locale.setlocale(locale.LC_ALL, 'de_DE') + +# 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} +% +% \end{macrocode} +%\fi +%\iffalse +% \begin{macrocode} +%<*post-merge.py> +% \end{macrocode} +%\fi +%\iffalse +% \begin{macrocode} +#!/usr/bin/env python +# -*- 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 +locale.setlocale(locale.LC_ALL, 'de_DE') + +# 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} +% +% \end{macrocode} +%\fi +%\iffalse +% \begin{macrocode} +%<*gitfile-info.gfi> +% \end{macrocode} +%\fi +%\iffalse +% \begin{macrocode} +% gitfile-info control file +\gfiSetDate{27}{06}{2016}{22}{39}{27. Juni 2016 22:39} +\gfiSetAuthor{André Hilbig}{mail@andrehilbig.de} +\gfiSetCommit{bad8f21c471b20eaba584a728b5809e9126370e3}{bad8f2}% \end{macrocode} +%\fi +%\iffalse +% \begin{macrocode} +% +% \end{macrocode} +%\fi +%\Finale +\endinput diff --git a/Master/texmf-dist/source/support/gitfile-info/gitfile-info.ins b/Master/texmf-dist/source/support/gitfile-info/gitfile-info.ins new file mode 100644 index 00000000000..b43faa43925 --- /dev/null +++ b/Master/texmf-dist/source/support/gitfile-info/gitfile-info.ins @@ -0,0 +1,35 @@ +% gitfile-info.ins generated using makedtx version 0.94b 2016-06-27:22:50:57 -- Version 0.1/6/27 22:50 +\input docstrip + +\preamble + + gitfile-info.dtx + Copyright 2016-06-27:22:50:57 -- Version 0.1 André Hilbig, mail@andrehilbig.de + + This work may be distributed and/or modified under the + conditions of the LaTeX Project Public License, either version 1.3 + of this license of (at your option) any later version. + The latest version of this license is in + http://www.latex-project.org/lppl.txt + and version 1.3 or later is part of all distributions of LaTeX + version 2005/12/01 or later. + + This work has the LPPL maintenance status `maintained'. + + The Current Maintainer of this work is André Hilbig, mail@andrehilbig.de. + + This work consists of the files gitfile-info.dtx and gitfile-info.ins and the derived files gitfile-info.sty, gfi-run.py, post-commit.py, post-merge.py, gitfile-info.gfi. + +\endpreamble + +\askforoverwritefalse + +\generate{\file{gitfile-info.sty}{\usepreamble\defaultpreamble +\usepostamble\defaultpostamble\from{gitfile-info.dtx}{gitfile-info.sty,package}} +\file{gfi-run.py}{\nopreamble\nopostamble\from{gitfile-info.dtx}{gfi-run.py}} +\file{post-commit.py}{\nopreamble\nopostamble\from{gitfile-info.dtx}{post-commit.py}} +\file{post-merge.py}{\nopreamble\nopostamble\from{gitfile-info.dtx}{post-merge.py}} +\file{gitfile-info.gfi}{\nopreamble\nopostamble\from{gitfile-info.dtx}{gitfile-info.gfi}} +} + +\endbatchfile diff --git a/Master/texmf-dist/tex/latex/gitfile-info/gitfile-info.sty b/Master/texmf-dist/tex/latex/gitfile-info/gitfile-info.sty new file mode 100644 index 00000000000..89dda52fad1 --- /dev/null +++ b/Master/texmf-dist/tex/latex/gitfile-info/gitfile-info.sty @@ -0,0 +1,144 @@ +%% +%% This is file `gitfile-info.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% gitfile-info.dtx (with options: `gitfile-info.sty,package') +%% +%% gitfile-info.dtx +%% Copyright 2016-06-27:22:50:57 -- Version 0.1 André Hilbig, mail@andrehilbig.de +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3 +%% of this license of (at your option) any later version. +%% The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.3 or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status `maintained'. +%% +%% The Current Maintainer of this work is André Hilbig, mail@andrehilbig.de. +%% +%% This work consists of the files gitfile-info.dtx and gitfile-info.ins and the derived files gitfile-info.sty, gfi-run.py, post-commit.py, post-merge.py, gitfile-info.gfi. +%% +%% \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 \~} +\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{\gfiGetHour}{#4} +\renewcommand{\gfiGetMin}{#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} +\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} +} +\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{\currfiledir\currfilebase} +} +\providecommand{\gfiInclude}[1]{% +\gfiInitInc{#1} +\include{#1} +\gfiInitInc{\currfiledir\currfilebase} +} +\endinput +%% +%% End of file `gitfile-info.sty'. diff --git a/Master/tlpkg/bin/tlpkg-ctan-check b/Master/tlpkg/bin/tlpkg-ctan-check index 742e26dd68e..c0f41044d1a 100755 --- a/Master/tlpkg/bin/tlpkg-ctan-check +++ b/Master/tlpkg/bin/tlpkg-ctan-check @@ -276,7 +276,8 @@ my @TLP_working = qw( getargs getfiledate getitems getmap getoptk gfnotation gfsartemisia gfsbaskerville gfsbodoni gfscomplutum gfsdidot gfsneohellenic gfsporson gfssolomos - ghab ghsystem gillcm gillius gincltex ginpenc gitinfo gitinfo2 gitlog + ghab ghsystem gillcm gillius gincltex ginpenc + gitfile-info gitinfo gitinfo2 gitlog gloss glossaries glossaries-danish glossaries-dutch glossaries-english glossaries-extra glossaries-french diff --git a/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc b/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc index 7abe431661e..bba0b02d3d6 100644 --- a/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc +++ b/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc @@ -443,6 +443,7 @@ depend getargs depend getfiledate depend getitems depend ginpenc +depend gitfile-info depend gitinfo depend gitinfo2 depend gitlog diff --git a/Master/tlpkg/tlpsrc/gitfile-info.tlpsrc b/Master/tlpkg/tlpsrc/gitfile-info.tlpsrc new file mode 100644 index 00000000000..e69de29bb2d -- cgit v1.2.3