Debian Codegraph @

texmf-dist/tex/lualatex/gitinfo-lua/gitinfo-lua.sty

raw
1 %% gitinfo-lua.sty
2 %% Copyright 2024 E. Nijenhuis
3 %
4 % This work may be distributed and/or modified under the
5 % conditions of the LaTeX Project Public License, either version 1.3c
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.3c or later is part of all distributions of LaTeX
10 % version 2005/12/01 or later.
11 %
12 % This work has the LPPL maintenance status ‘maintained’.
13 %
14 % The Current Maintainer of this work is E. Nijenhuis.
15 %
16 % This work consists of the files gitinfo-lua.sty gitinfo-lua.pdf
17 % gitinfo-lua-cmd.lua, gitinfo-lua-recorder.lua and gitinfo-lua.lua
18 \NeedsTeXFormat{LaTeX2e}
19 \ProvidesPackage{gitinfo-lua}[2024/09/14 1.2.0 Xerdi's Git Package]
20
21 \directlua{git = require('gitinfo-lua')}
22
23 \RequirePackage{pgfopts}
24
25 \newif\ifgit@multipleauthors
26 \newif\ifgit@setmacros
27 \newif\ifgit@toroot
28 \pgfkeys{/gitinfo-lua/.is family,
29 /gitinfo-lua,
30 author sort/.default=false,
31 author sort/.store in=\git@author@sort,
32 author sort,
33 contrib/.style = {/git/author sort=true},
34 alpha/.style = {/git/author sort=false},
35 multiple authors/.is if=git@multipleauthors,
36 multiple authors=false,
37 author/.style={multiple authors=false},
38 authors/.style={multiple authors=true},
39 set title page macros/.is if=git@setmacros,
40 set title page macros=false,
41 titlepage/.style={set title page macros=true},
42 rootdir/.is if=git@toroot,
43 rootdir=false
44 }
45
46 \ProcessPgfPackageOptions*
47
48 \newcommand*\git@single@arg[1]{#1}
49
50 \newcommand*\gitversion{\directlua{git:write_version()}}
51 \newcommand*\gitauthor{\directlua{git:write_local_author()}}
52 \newcommand*\gitemail{\directlua{git:write_local_email()}}
53 \newcommand*\gitdate{\directlua{git:cs_last_commit('git@single@arg', 'cs')}}
54 \newcommand*\gitdirectory[1]{\directlua{git:dir('#1')}}
55 \newcommand*\gitunsetdirectory{\directlua{git:dir(nil)}}
56 \newcommand*\ifgitdirty[2]{%
57 \def\@dirtytrue{1}%
58 \edef\@dirty{\directlua{git:write_is_dirty()}}%
59 \ifx\@dirty\@dirtytrue
60 #1%
61 \else
62 #2%
63 \fi
64 }
65
66 \newcommand\git@format@author[2]{%
67 #1
68 \ifcsname href\endcsname%
69 \textlangle\href{mailto:#2}{#2}\textrangle%
70 \else%
71 \textlangle\texttt{#2}\textrangle%
72 \fi%
73 }
74
75 \newcommand*\dogitauthors[1][,~]{%
76 \directlua{git:cs_for_authors('git@format@author', '#1', \git@author@sort)}%
77 }
78
79 \newcommand*\forgitauthors[2][\authorconjunction]{%
80 \directlua{git:cs_for_authors('#2', '#1', \git@author@sort)}%
81 }
82
83 \def\git@default@tag@format{refname:short,(taggername)(taggername,taggeremail,taggerdate:short)(authorname,authoremail,authordate:short),subject,body}
84 \newcommand{\gitcommit}[3][h,an,ae,as,s,b]{\directlua{git:cs_commit('#2', '#3', '#1')}}
85 \newcommand{\forgitcommit}[3][h,an,ae,as,s,b]{\directlua{git:cs_for_commit('#2', '#3', '#1')}}
86 \newcommand{\gittag}[3][\git@default@tag@format]{%
87 \directlua{git:cs_tag('#2', '#1', '#3')}%
88 }
89 \newcommand{\forgittag}[2][\git@default@tag@format]{%
90 \directlua{git:cs_for_tag('#2', '#1')}%
91 }
92 \newcommand{\forgittagseq}[1]{\directlua{git:cs_for_tag_sequence('#1')}}
93
94 \ifgit@toroot
95 \directlua{git:dir_to_root()}
96 \fi
97
98 \ifgit@setmacros
99 \ifgit@multipleauthors
100 \author{\dogitauthors[\\\\]}
101 \else
102 \author{\gitauthor}
103 \fi
104 \directlua{git:set_date()}
105 \date{\today}
106 \fi
107
108 \endinput