texlive[70849] Master/texmf-dist: gitinfo-lua (3apr24)

commits+karl at tug.org commits+karl at tug.org
Wed Apr 3 23:17:51 CEST 2024


Revision: 70849
          https://tug.org/svn/texlive?view=revision&revision=70849
Author:   karl
Date:     2024-04-03 23:17:51 +0200 (Wed, 03 Apr 2024)
Log Message:
-----------
gitinfo-lua (3apr24)

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-cmd.lua
    trunk/Master/texmf-dist/scripts/gitinfo-lua/gitinfo-lua.lua
    trunk/Master/texmf-dist/tex/lualatex/gitinfo-lua/gitinfo-lua.sty

Added Paths:
-----------
    trunk/Master/texmf-dist/scripts/gitinfo-lua/gitinfo-lua-recorder.lua

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-04-03 21:16:41 UTC (rev 70848)
+++ trunk/Master/texmf-dist/doc/lualatex/gitinfo-lua/gitinfo-lua.tex	2024-04-03 21:17:51 UTC (rev 70849)
@@ -103,6 +103,7 @@
     Note that in both cases option \texttt{-shell-escape} is required.
     This is required for issuing \texttt{git} via the commandline.
 
+    When utilizing the continuous compilation option \texttt{-pvc} with \texttt{latexmk}, it's important to note that only committed changes will be detected, while tag changes, unfortunately, won't be recognized.
 
     \section{LaTeX Interface}
 

Modified: trunk/Master/texmf-dist/scripts/gitinfo-lua/gitinfo-lua-cmd.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/gitinfo-lua/gitinfo-lua-cmd.lua	2024-04-03 21:16:41 UTC (rev 70848)
+++ trunk/Master/texmf-dist/scripts/gitinfo-lua/gitinfo-lua-cmd.lua	2024-04-03 21:17:51 UTC (rev 70849)
@@ -1,5 +1,5 @@
 -- gitinfo-lua-cmd.lua
--- Copyright 2023 E. Nijenhuis
+-- Copyright 2024 E. Nijenhuis
 --
 -- This work may be distributed and/or modified under the
 -- conditions of the LaTeX Project Public License, either version 1.3c
@@ -14,7 +14,7 @@
 -- The Current Maintainer of this work is E. Nijenhuis.
 --
 -- This work consists of the files gitinfo-lua.sty gitinfo-lua.pdf
--- gitinfo-cmd.lua and gitinfo-lua.lua
+-- gitinfo-lua-cmd.lua, gitinfo-lua-recorder.lua and gitinfo-lua.lua
 
 local api = {
     cwd = nil,
@@ -21,7 +21,8 @@
     executable = 'git',
     default_sort = '',
     attribute_separator = '\\pop',
-    record_separator = '\\end'
+    record_separator = '\\end',
+    recorder = require('gitinfo-lua-recorder')
 }
 local cache = {}
 function cache:seek(_key)
@@ -40,6 +41,7 @@
 function api:exec(command, do_caching, target_dir)
     local cmd = self.executable .. ' ' .. command
     local cwd = target_dir or self.cwd
+    api.recorder.record_head(cwd)
     if cwd then
         cmd = 'cd ' .. cwd .. ' && ' .. cmd
     end

Added: trunk/Master/texmf-dist/scripts/gitinfo-lua/gitinfo-lua-recorder.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/gitinfo-lua/gitinfo-lua-recorder.lua	                        (rev 0)
+++ trunk/Master/texmf-dist/scripts/gitinfo-lua/gitinfo-lua-recorder.lua	2024-04-03 21:17:51 UTC (rev 70849)
@@ -0,0 +1,79 @@
+-- gitinfo-lua-recorder.lua
+-- Copyright 2024 E. Nijenhuis
+--
+-- This work may be distributed and/or modified under the
+-- conditions of the LaTeX Project Public License, either version 1.3c
+-- of this license or (at your option) any later version.
+-- The latest version of this license is in
+-- http://www.latex-project.org/lppl.txt
+-- and version 1.3c 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 E. Nijenhuis.
+--
+-- This work consists of the files gitinfo-lua.sty gitinfo-lua.pdf
+-- gitinfo-lua-cmd.lua, gitinfo-lua-recorder.lua and gitinfo-lua.lua
+
+local kpse = kpse or require('kpse')
+local texio = texio or require('texio')
+
+local api = {
+    record_list = {}
+}
+
+---record_head
+---Records .git/HEAD and .git/refs/heads/<branch> respectively,
+---in order to trigger a rebuild in LaTeX.
+--- at param git_directory string
+function api.record_head(git_directory)
+    local head_path = '.git/HEAD'
+    if git_directory then
+        head_path = git_directory .. head_path
+    end
+    if not api.record_list[head_path] then
+        api.record_list[head_path] = true
+        if kpse.in_name_ok(head_path) then
+            local head_file = io.open(head_path, 'rb')
+            if not head_file then
+                texio.write_nl('Warning: couldn\'t read HEAD from git project directory')
+                return
+            end
+            kpse.record_input_file(head_path)
+            texio.write_nl('Info: recording input file ' .. head_path)
+            local head_info = head_file:read('*a')
+            head_file:close()
+            local i, j = string.find(head_info, '^ref: .+\n$')
+            local ref_path = string.sub(head_info, i + 5, j-1)
+            if not ref_path then
+                texio.write_nl('Warning: couldn\'t find ref of HEAD')
+                return
+            end
+            ref_path = '.git/' .. ref_path
+            if git_directory then
+                ref_path = git_directory .. ref_path
+            end
+            if kpse.in_name_ok(ref_path) then
+                kpse.record_input_file(ref_path)
+                texio.write_nl('Info: recording input file ' .. ref_path)
+            else
+                texio.write_nl('Warning: couldn\'t read ref file: ' .. ref_path)
+            end
+        else
+            texio.write_nl('Couldn\'t open input file ' .. head_path)
+        end
+    end
+end
+
+
+
+local gitinfo_recorder = {}
+local gitinfo_recorder_mt = {
+    __index = api,
+    __newindex = nil
+}
+
+setmetatable(gitinfo_recorder, gitinfo_recorder_mt)
+
+return gitinfo_recorder


Property changes on: trunk/Master/texmf-dist/scripts/gitinfo-lua/gitinfo-lua-recorder.lua
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/scripts/gitinfo-lua/gitinfo-lua.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/gitinfo-lua/gitinfo-lua.lua	2024-04-03 21:16:41 UTC (rev 70848)
+++ trunk/Master/texmf-dist/scripts/gitinfo-lua/gitinfo-lua.lua	2024-04-03 21:17:51 UTC (rev 70849)
@@ -1,5 +1,5 @@
 -- gitinfo-lua.lua
--- Copyright 2023 E. Nijenhuis
+-- Copyright 2024 E. Nijenhuis
 --
 -- This work may be distributed and/or modified under the
 -- conditions of the LaTeX Project Public License, either version 1.3c
@@ -14,7 +14,7 @@
 -- The Current Maintainer of this work is E. Nijenhuis.
 --
 -- This work consists of the files gitinfo-lua.sty gitinfo-lua.pdf
--- gitinfo-cmd.lua and gitinfo-lua.lua
+-- gitinfo-lua-cmd.lua, gitinfo-lua-recorder.lua and gitinfo-lua.lua
 
 if not modules then
     modules = {}
@@ -23,8 +23,8 @@
 local module = {
     name = 'gitinfo-lua',
     info = {
-        version = '1.0.2', --TAGVERSION
-        date    = '2024/02/23',       --TAGDATE
+        version = '1.0.3',            --TAGVERSION
+        date    = '2024/04/02',       --TAGDATE
         comment = "Git info Lua — Git integration with LaTeX",
         author  = "Erik Nijenhuis",
         license = "free"
@@ -81,58 +81,6 @@
     return buf
 end
 
--- experimental
-function api:get_tok()
-    if self.cur_tok == nil then
-        self.cur_tok = token.get_next()
-    end
-    return self.cur_tok
-end
-
--- experimental
-function api:parse_opts()
-    local tok = self:get_tok()
-    if tok.cmdname == 'other_char' then
-        --token.put_next(tok)
-        local opts = token.scan_word()
-        self.cur_tok = nil
-        -- todo: parse []
-        return opts
-    end
-end
-
--- experimental
-function api:parse_arguments(argc)
-    local result_list = {}
-    for _ = 1, argc do
-        local tok = self:get_tok()
-        if tok.cmdname == 'left_brace' then
-            token.put_next(tok)
-            table.insert(result_list, token.scan_argument())
-            self.cur_tok = nil
-        else
-            tex.error("Expected left brace")
-            return
-        end
-    end
-    return table.unpack(result_list)
-end
-
--- experimental
-function api:parse_macro()
-    --tex.print('\\noexpand')
-    local tok = self:get_tok()
-    if (tok.cmdname == 'call') or tok.cmdname == 'long_call' then
-        self.cur_tok = nil
-        return tok
-    else
-        tex.error("Expected Macro")
-        for i = 1, 5 do
-            local _tok = token.get_next()
-        end
-    end
-end
-
 function api:dir(path)
     self.cmd.cwd = path
 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-04-03 21:16:41 UTC (rev 70848)
+++ trunk/Master/texmf-dist/tex/lualatex/gitinfo-lua/gitinfo-lua.sty	2024-04-03 21:17:51 UTC (rev 70849)
@@ -1,5 +1,5 @@
 %% gitinfo-lua.sty
-%% Copyright 2023 E. Nijenhuis
+%% Copyright 2024 E. Nijenhuis
 %
 % This work may be distributed and/or modified under the
 % conditions of the LaTeX Project Public License, either version 1.3c
@@ -14,9 +14,9 @@
 % The Current Maintainer of this work is E. Nijenhuis.
 %
 % This work consists of the files gitinfo-lua.sty gitinfo-lua.pdf
-% gitinfo-cmd.lua and gitinfo-lua.lua
+% gitinfo-lua-cmd.lua, gitinfo-lua-recorder.lua and gitinfo-lua.lua
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{gitinfo-lua}[2024/02/23 1.0.2 Xerdi's Git Package]
+\ProvidesPackage{gitinfo-lua}[2024/04/02 1.0.3 Xerdi's Git Package]
 
 \RequirePackage{luacode}
 



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