diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/latexgit/latexgit.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/latexgit/latexgit.sty | 154 |
1 files changed, 80 insertions, 74 deletions
diff --git a/Master/texmf-dist/tex/latex/latexgit/latexgit.sty b/Master/texmf-dist/tex/latex/latexgit/latexgit.sty index e6fd11b02fb..f89079ab67e 100644 --- a/Master/texmf-dist/tex/latex/latexgit/latexgit.sty +++ b/Master/texmf-dist/tex/latex/latexgit/latexgit.sty @@ -8,7 +8,7 @@ %% latexgit %% Author: Camil Staps <info@camilstaps.nl> \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{latexgit}[2016/08/24] +\ProvidesPackage{latexgit}[2020/03/18] \RequirePackage{pgfkeys} \RequirePackage{datetime} @@ -22,6 +22,7 @@ /git/.is family, /git, default/.style={ directory=., + file=, formatDate=false, formatInterDateTime=\space{}at\space{}, formatTime=false, @@ -30,6 +31,7 @@ shortHash=true, }, directory/.estore in=\git@opt@Directory, + file/.estore in=\git@opt@File, formatDate/.is if=git@opt@FormatDate, formatInterDateTime/.estore in=\git@opt@FormatInterDateTime, formatTime/.is if=git@opt@FormatTime, @@ -54,100 +56,104 @@ \endgroup% \fi% } -\newcommand{\gitcommithash}[1][]{% +\catcode`\&=14\catcode`\%=11 +\def\git@space{ } +\newcommand{\gitcommithash}[1][]{& \git@commithash[#1]\git@result} -\newcommand{\git@commithash}[1][]{% - \pgfkeys{/git,default,#1}% - \ifgit@opt@ShortHash% - \git@command{git log -n 1 --oneline \git@opt@Revision - | cut -d' ' -f1}% - \else% - \git@command{git log -n 1 \git@opt@Revision - | head -1 | cut -d' ' -f2}% - \fi% +\newcommand{\git@commithash}[1][]{& + \pgfkeys{/git,default,#1}& + \ifgit@opt@ShortHash& + \git@command{git log -n 1 --format=%h + \git@opt@Revision\git@space -- \git@opt@File}& + \else& + \git@command{git log -n 1 --format=%H + \git@opt@Revision\git@space -- \git@opt@File}& + \fi& } -\newcommand{\gitcommitmsg}[1][]{% +\newcommand{\gitcommitmsg}[1][]{& \git@commitmsg[#1]\git@result} -\newcommand{\git@commitmsg}[1][]{% - \pgfkeys{/git,default,#1}% - \git@command{git log -n 1 --oneline \git@opt@Revision - | cut -d' ' -f2-}% +\newcommand{\git@commitmsg}[1][]{& + \pgfkeys{/git,default,#1}& + \git@command{git log -n 1 --format=%B + \git@opt@Revision\git@space -- \git@opt@File}& } -\def\git@formatCommitDate#1-#2-#3 #4:#5:#6 +#7\relax{% - \formatdate{#3}{#2}{#1}% +\def\git@formatCommitDate#1-#2-#3 #4:#5:#6 +#7\relax{& + \formatdate{#3}{#2}{#1}& } -\def\git@formatCommitTime#1-#2-#3 #4:#5:#6 +#7\relax{% - \formattime{#4}{#5}{#6}% - \ifgit@opt@ShowTimeZone% - \space(+#7\unskip)% - \fi% +\def\git@formatCommitTime#1-#2-#3 #4:#5:#6 +#7\relax{& + \formattime{#4}{#5}{#6}& + \ifgit@opt@ShowTimeZone& + \space(+#7\unskip)& + \fi& } -\newcommand{\gitcommitdate}[1][]{% - \git@commitdate[#1]% - \ifgit@opt@FormatDate% - \expandafter\git@formatCommitDate\git@rawresult\relax% - \ifgit@opt@FormatTime% - \git@opt@FormatInterDateTime% - \expandafter\git@formatCommitTime\git@rawresult\relax% +\newcommand{\gitcommitdate}[1][]{& + \git@commitdate[#1]& + \ifgit@opt@FormatDate& + \expandafter\git@formatCommitDate\git@rawresult\relax& + \ifgit@opt@FormatTime& + \git@opt@FormatInterDateTime& + \expandafter\git@formatCommitTime\git@rawresult\relax& \fi - \else\ifgit@opt@FormatTime% - \expandafter\git@formatCommitTime\git@rawresult\relax% + \else\ifgit@opt@FormatTime& + \expandafter\git@formatCommitTime\git@rawresult\relax& \else - \git@result% - \fi\fi% + \git@result& + \fi\fi& } -\newcommand{\git@commitdate}[1][]{% - \pgfkeys{/git,default,#1}% - \git@command{git log -n 1 --date=iso \git@opt@Revision - | grep Date | head -1 | cut -d' ' -f2-}% +\newcommand{\git@commitdate}[1][]{& + \pgfkeys{/git,default,#1}& + \git@command{git log -n 1 --format=%ai + \git@opt@Revision\git@space -- \git@opt@File}& } -\newcommand{\gitcommitauthor}[1][]{% +\newcommand{\gitcommitauthor}[1][]{& \git@commitauthor[#1]\git@result} -\newcommand{\git@commitauthor}[1][]{% - \pgfkeys{/git,default,#1}% - \git@command{git log -n 1 \git@opt@Revision - | grep Author | head -1 | cut -d' ' -f2-}% +\newcommand{\git@commitauthor}[1][]{& + \pgfkeys{/git,default,#1}& + \git@command{git log -n 1 --format='%an <%ae>' + \git@opt@Revision\git@space -- \git@opt@File}& } -\newcommand{\gitcommitauthorname}[1][]{% +\newcommand{\gitcommitauthorname}[1][]{& \git@commitauthorname[#1]\git@result} -\newcommand{\git@commitauthorname}[1][]{% - \pgfkeys{/git,default,#1}% - \git@command{git log -n 1 \git@opt@Revision - | grep Author | head -1 | cut -d' ' -f2- | cut -d'<' -f1}% +\newcommand{\git@commitauthorname}[1][]{& + \pgfkeys{/git,default,#1}& + \git@command{git log -n 1 --format=%an + \git@opt@Revision\git@space -- \git@opt@File}& } -\newcommand{\gitcommitauthoremail}[1][]{% +\newcommand{\gitcommitauthoremail}[1][]{& \git@commitauthoremail[#1]\git@result} -\newcommand{\git@commitauthoremail}[1][]{% - \pgfkeys{/git,default,#1}% - \git@command{git log -n 1 \git@opt@Revision - | grep Author | head -1 | cut -d' ' -f2- - | cut -d'<' -f2 | cut -d'>' -f1}% +\newcommand{\git@commitauthoremail}[1][]{& + \pgfkeys{/git,default,#1}& + \git@command{git log -n 1 --format=%ae + \git@opt@Revision\git@space -- \git@opt@File}& } -\newcommand{\git@commitparent}[1][]{% - \pgfkeys{/git,default,#1}% - \git@command{git log -n 1 --pretty=raw \git@opt@Revision - | grep parent | head -1 | cut -d' ' -f2}% +\newcommand{\git@commitparent}[1][]{& + \pgfkeys{/git,default,#1}& + \git@command{git log -n 1 --format=%p + \git@opt@Revision\git@space -- \git@opt@File + | cut -d' ' -f2}& } -\newcommand{\gitchanges}[1][]{% +\newcommand{\gitchanges}[1][]{& \git@changes[#1]{HEAD} } -\newcommand{\git@changes}[2][]{% - \edef\git@@revision{#2}% - \git@commithash[revision=\git@@revision]% - \edef\git@@thishash{\git@rawresult}% - \git@command{git log -n 1 --date=iso \git@@revision - | grep Date | head -1 | cut -d' ' -f4}% - \edef\git@@thisdate{\git@rawresult}% - \git@commitmsg[revision=\git@@revision]% - \edef\git@@thismsg{\git@rawresult}% - \changes{\git@@thisdate\unskip: \git@@thishash}\git@@thisdate\git@@thismsg% - \git@commitparent[revision=\git@@revision]% - \let\git@@parent\git@rawresult% +\newcommand{\git@changes}[2][]{& + \edef\git@@revision{#2}& + \git@commithash[revision=\git@@revision]& + \edef\git@@thishash{\git@rawresult}& + \git@command{git log -n 1 --format=%ad --date=short \git@opt@Revision}& + \edef\git@@thisdate{\git@rawresult}& + \git@commitmsg[revision=\git@@revision]& + & TODO: this removes '=' characters because they break \changes, but the real + & solution would be to put something back that restores these characters. + \StrSubstitute[0]{\git@rawresult}{=}{}[\git@@thismsg]& + \changes{\git@@thisdate\unskip: \git@@thishash}{\git@@thisdate}{\git@@thismsg}& + \git@commitparent[revision=\git@@revision]& + \let\git@@parent\git@rawresult& \setbox0=\hbox{\git@@parent\unskip}\ifdim\wd0=0pt - \else% - \git@changes{\git@@parent}% - \fi% + \else& + \git@changes{\git@@parent}& + \fi& } +\catcode`\&=4\catcode`\%=14 %% Copyright (c) 2016 Camil Staps <info@camilstaps.nl> %% Licensed under GPL v3. %% |