texlive[72284] Master/texmf-dist: gitinfo-lua (14sep24)

commits+karl at tug.org commits+karl at tug.org
Sat Sep 14 21:25:22 CEST 2024


Revision: 72284
          https://tug.org/svn/texlive?view=revision&revision=72284
Author:   karl
Date:     2024-09-14 21:25:22 +0200 (Sat, 14 Sep 2024)
Log Message:
-----------
gitinfo-lua (14sep24)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/lualatex/gitinfo-lua/gitinfo-lua.pdf
    trunk/Master/texmf-dist/doc/lualatex/gitinfo-lua/gitinfo-lua.tex
    trunk/Master/texmf-dist/scripts/gitinfo-lua/gitinfo-lua.lua
    trunk/Master/texmf-dist/tex/lualatex/gitinfo-lua/gitinfo-lua.sty

Modified: trunk/Master/texmf-dist/doc/lualatex/gitinfo-lua/gitinfo-lua.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/lualatex/gitinfo-lua/gitinfo-lua.tex
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/gitinfo-lua/gitinfo-lua.tex	2024-09-14 19:25:12 UTC (rev 72283)
+++ trunk/Master/texmf-dist/doc/lualatex/gitinfo-lua/gitinfo-lua.tex	2024-09-14 19:25:22 UTC (rev 72284)
@@ -157,6 +157,9 @@
     When the version is dirty it will be post fixed with \texttt{-<commit count>-<short ref>}.
     For example, when this paragraph was written, the version was displaying 0.0.1-14-gcc2bc30.\\
 
+    \DescribeMacro{\ifgitdirty} To test whether there are any pending changes in the local Git repository, use the \cmd{\ifgitdirty}\marg{true code}\marg{false code} macro.
+    For this macro to work properly, be sure to add a \texttt{.gitignore}\footnote{A proper example of a \texttt{.gitignore} file for \LaTeX: \url{https://raw.githubusercontent.com/github/gitignore/main/TeX.gitignore}} file and include all \TeX\ based generated files.\\
+
     The \DescribeMacro{\gitdate}\cmd{\gitdate} macro gets the most recent date from the git log.
     Meaning, the last `short date' variant is picked from the last commit.
     This short date is formatted ISO based and is already suitable for use in packages like \texttt{isodate} for more advanced date formatting.\\
@@ -201,7 +204,6 @@
     For this section the git project of this document is used due to the fact that there are references to revisions.
     The test project's revisions change for every user, since they get recreated every time \texttt{test-scenario.sh} is executed (see section~\ref{sec:project}).\\
 
-    \clearpage
     \noindent
     \DescribeMacro{\gitcommit}\oarg{format}\marg{csname}\marg{revision}\\
     For displaying commit data \cmd{\gitcommit} can be used.

Modified: trunk/Master/texmf-dist/scripts/gitinfo-lua/gitinfo-lua.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/gitinfo-lua/gitinfo-lua.lua	2024-09-14 19:25:12 UTC (rev 72283)
+++ trunk/Master/texmf-dist/scripts/gitinfo-lua/gitinfo-lua.lua	2024-09-14 19:25:22 UTC (rev 72284)
@@ -23,8 +23,8 @@
 local module = {
     name = 'gitinfo-lua',
     info = {
-        version = '1.1.0',            --TAGVERSION
-        date    = '2024/04/11',       --TAGDATE
+        version = '1.2.0',            --TAGVERSION
+        date    = '2024/09/14',       --TAGDATE
         comment = "Git info Lua — Git integration with LaTeX",
         author  = "Erik Nijenhuis",
         license = "free"
@@ -109,10 +109,23 @@
     end
 end
 
+function api:is_dirty()
+    local files_changed, _ = self.cmd:exec('status --porcelain=1', true)
+    return files_changed and #files_changed > 0
+end
+
+function api:write_is_dirty()
+    if self:is_dirty() then
+        tex.write('1')
+    else
+        tex.write('0')
+    end
+end
+
 -- todo: prevent output to stderr
 -- todo: add write variant
 -- experimental
-function api:is_dirty()
+function api:is_tag()
     local ok, _ = self.cmd:exec('describe --tags --exact-match')
     return ok == nil
 end

Modified: trunk/Master/texmf-dist/tex/lualatex/gitinfo-lua/gitinfo-lua.sty
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/gitinfo-lua/gitinfo-lua.sty	2024-09-14 19:25:12 UTC (rev 72283)
+++ trunk/Master/texmf-dist/tex/lualatex/gitinfo-lua/gitinfo-lua.sty	2024-09-14 19:25:22 UTC (rev 72284)
@@ -16,7 +16,7 @@
 % This work consists of the files gitinfo-lua.sty gitinfo-lua.pdf
 % gitinfo-lua-cmd.lua, gitinfo-lua-recorder.lua and gitinfo-lua.lua
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{gitinfo-lua}[2024/04/11 1.1.0 Xerdi's Git Package]
+\ProvidesPackage{gitinfo-lua}[2024/09/14 1.2.0 Xerdi's Git Package]
 
 \directlua{git = require('gitinfo-lua')}
 
@@ -53,6 +53,15 @@
 \newcommand*\gitdate{\directlua{git:cs_last_commit('git at single@arg', 'cs')}}
 \newcommand*\gitdirectory[1]{\directlua{git:dir('#1')}}
 \newcommand*\gitunsetdirectory{\directlua{git:dir(nil)}}
+\newcommand*\ifgitdirty[2]{%
+    \def\@dirtytrue{1}%
+    \edef\@dirty{\directlua{git:write_is_dirty()}}%
+    \ifx\@dirty\@dirtytrue
+        #1%
+    \else
+        #2%
+    \fi
+}
 
 \newcommand\git at format@author[2]{%
     #1



More information about the tex-live-commits mailing list.