summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2024-04-03 21:17:51 +0000
committerKarl Berry <karl@freefriends.org>2024-04-03 21:17:51 +0000
commitb033809ee9e0148a20f37328bb519f0cd0afbb0a (patch)
treec8729c4a71d2900713f3a572f9775e20eb373a83 /Master
parentf525d07b31d375ec7bdd3078768c3b979bccac44 (diff)
gitinfo-lua (3apr24)
git-svn-id: svn://tug.org/texlive/trunk@70849 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf-dist/doc/lualatex/gitinfo-lua/gitinfo-lua.pdfbin115812 -> 116004 bytes
-rw-r--r--Master/texmf-dist/doc/lualatex/gitinfo-lua/gitinfo-lua.tex1
-rw-r--r--Master/texmf-dist/scripts/gitinfo-lua/gitinfo-lua-cmd.lua8
-rw-r--r--Master/texmf-dist/scripts/gitinfo-lua/gitinfo-lua-recorder.lua79
-rw-r--r--Master/texmf-dist/scripts/gitinfo-lua/gitinfo-lua.lua60
-rw-r--r--Master/texmf-dist/tex/lualatex/gitinfo-lua/gitinfo-lua.sty6
6 files changed, 92 insertions, 62 deletions
diff --git a/Master/texmf-dist/doc/lualatex/gitinfo-lua/gitinfo-lua.pdf b/Master/texmf-dist/doc/lualatex/gitinfo-lua/gitinfo-lua.pdf
index 02edd681a71..693b905da37 100644
--- a/Master/texmf-dist/doc/lualatex/gitinfo-lua/gitinfo-lua.pdf
+++ b/Master/texmf-dist/doc/lualatex/gitinfo-lua/gitinfo-lua.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/lualatex/gitinfo-lua/gitinfo-lua.tex b/Master/texmf-dist/doc/lualatex/gitinfo-lua/gitinfo-lua.tex
index ef7781dd01f..fe7bdd4e977 100644
--- a/Master/texmf-dist/doc/lualatex/gitinfo-lua/gitinfo-lua.tex
+++ b/Master/texmf-dist/doc/lualatex/gitinfo-lua/gitinfo-lua.tex
@@ -103,6 +103,7 @@ latexmk -pvc -lualatex -shell-escape main
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}
diff --git a/Master/texmf-dist/scripts/gitinfo-lua/gitinfo-lua-cmd.lua b/Master/texmf-dist/scripts/gitinfo-lua/gitinfo-lua-cmd.lua
index 5aa0dc56e55..68ac3c09a9b 100644
--- a/Master/texmf-dist/scripts/gitinfo-lua/gitinfo-lua-cmd.lua
+++ b/Master/texmf-dist/scripts/gitinfo-lua/gitinfo-lua-cmd.lua
@@ -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,14 +14,15 @@
-- 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,
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 @@ end
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
diff --git a/Master/texmf-dist/scripts/gitinfo-lua/gitinfo-lua-recorder.lua b/Master/texmf-dist/scripts/gitinfo-lua/gitinfo-lua-recorder.lua
new file mode 100644
index 00000000000..8d4aa78af23
--- /dev/null
+++ b/Master/texmf-dist/scripts/gitinfo-lua/gitinfo-lua-recorder.lua
@@ -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.
+---@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
diff --git a/Master/texmf-dist/scripts/gitinfo-lua/gitinfo-lua.lua b/Master/texmf-dist/scripts/gitinfo-lua/gitinfo-lua.lua
index 0f3a1315d3e..cba19b19d78 100644
--- a/Master/texmf-dist/scripts/gitinfo-lua/gitinfo-lua.lua
+++ b/Master/texmf-dist/scripts/gitinfo-lua/gitinfo-lua.lua
@@ -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 @@ end
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 @@ function api:escape_str(value)
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
diff --git a/Master/texmf-dist/tex/lualatex/gitinfo-lua/gitinfo-lua.sty b/Master/texmf-dist/tex/lualatex/gitinfo-lua/gitinfo-lua.sty
index 3f850a1146e..c9ab3a4cd6a 100644
--- a/Master/texmf-dist/tex/lualatex/gitinfo-lua/gitinfo-lua.sty
+++ b/Master/texmf-dist/tex/lualatex/gitinfo-lua/gitinfo-lua.sty
@@ -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}