2 % Copyright 2011 Brent Longborough
4 % This work may be distributed and/or modified under the
5 % conditions of the LaTeX Project Public License, either version 1.3
6 % of this license or (at your option) any later version.
7 % The latest version of this license is in
8 % http://www.latex-project.org/lppl.txt
9 % and version 1.3 or later is part of all distributions of LaTeX
10 % version 2005/12/01 or later.
12 % This work has the LPPL maintenance status `maintained'.
13 % The Current Maintainer of this work is Brent Longborough.
15 % This work consists of these files:
16 % gitinfo.sty, gitsetinfo.sty, gitinfo.tex, gitinfo.pdf,
17 % post-git-sample.txt, and gitHeadInfo.gin
18 % -----------------------------------------------------
19 \NeedsTeXFormat{LaTeX2e}
20 \ProvidesPackage{gitinfo}[2011/08/10 v1.00 git revision information]
21 \RequirePackage{etoolbox}
22 \RequirePackage{kvoptions}
27 \DeclareBoolOption{grumpy}
28 \DeclareBoolOption{pcount}
29 \DeclareBoolOption{footinfo}
30 \DeclareStringOption[(None)]{missing}
31 \ProcessKeyvalOptions*
32 \newcommand{\gitAbbrevHash}{\gitInf@missing}
33 \newcommand{\gitHash}{\gitInf@missing}
34 \newcommand{\gitAuthorName}{\gitInf@missing}
35 \newcommand{\gitAuthorEmail}{\gitInf@missing}
36 \newcommand{\gitAuthorDate}{\gitInf@missing}
37 \newcommand{\gitAuthorIsoDate}{\gitInf@missing}
38 \newcommand{\gitAuthorUnixDate}{\gitInf@missing}
39 \newcommand{\gitCommitterName}{\gitInf@missing}
40 \newcommand{\gitCommitterEmail}{\gitInf@missing}
41 \newcommand{\gitCommitterDate}{\gitInf@missing}
42 \newcommand{\gitCommitterIsoDate}{\gitInf@missing}
43 \newcommand{\gitCommitterUnixDate}{\gitInf@missing}
44 \newcommand{\gitReferences}{\gitInf@missing}
45 \newcommand{\gitVtag}{}
46 \newcommand{\gitVtags}{}
47 \newcommand{\gitVtagn}{\space\gitInf@missing}
48 \InputIfFileExists{./gitHeadInfo.gin}{}{%
49 \ifbool{gitInf@grumpy}{%
50 \PackageError{gitinfo}{I can't find the file `gitHeadInfo.gin`.\MessageBreak
51 Please check the manual (gitinfo.pdf) \MessageBreak
52 if you need more details.}{}
54 \PackageWarning{gitInfo}{I can't find the file `gitHeadInfo.gin`.\MessageBreak
55 All git metadata has been set to ``\gitInf@missing''.}
58 \@ifclassloaded{memoir}{%
59 \ifbool{gitInf@footinfo}{%
60 \ifbool{gitInf@pcount}{
61 \newcommand{\@gitPage}{\thepage/\thelastpage}
62 \addtodef{\frontmatter}{\renewcommand{\@gitPage}{\thepage}}{}
63 \addtodef{\mainmatter}{}{\renewcommand{\@gitPage}{\thepage/\thelastpage}}
65 \newcommand{\@gitPage}{\thepage}
67 \newcommand{\@gitFootRev}{Revision\gitVtags: \gitAbbrevHash{} (\gitAuthorDate)}
68 \newcommand{\@gitrFootRev}{%
69 \tiny\textsf{\raggedleft \@gitFootRev}%
71 \newcommand{\@gitlFootRev}{%
72 \tiny\textsf{\@gitFootRev}%
74 \makeevenfoot{plain}{\@gitPage}{}{\@gitrFootRev}
75 \makeoddfoot{plain}{\@gitlFootRev}{}{\@gitPage}
76 \makeevenfoot{ruled}{\@gitPage}{}{\@gitrFootRev}
77 \makeoddfoot{ruled}{\@gitlFootRev}{}{\@gitPage}
78 \makeevenfoot{headings}{\@gitPage}{}{\@gitrFootRev}
79 \makeoddfoot{headings}{\@gitlFootRev}{}{\@gitPage}
80 \makeevenhead{headings}{}{}{\slshape\leftmark}
81 \makeoddhead{headings}{\slshape\rightmark}{}{}