summaryrefslogtreecommitdiffstats
path: root/config/macros.tex
diff options
context:
space:
mode:
Diffstat (limited to 'config/macros.tex')
-rw-r--r--config/macros.tex28
1 files changed, 28 insertions, 0 deletions
diff --git a/config/macros.tex b/config/macros.tex
index f674bfa..dba337e 100644
--- a/config/macros.tex
+++ b/config/macros.tex
@@ -364,6 +364,34 @@ end
\newcommand\XXX{\textcolor{Magenta}{(XXX)}}
%%
+%% Pour afficher le numéro de version Git (exige que LuaTeX soit appelé avec --shell-escape)
+%%
+
+\catcode`\%=12
+\directlua{
+function command_output(cmd)
+ local output_pipe = io.popen(cmd)
+ local line_iter = output_pipe and output_pipe:lines()
+ local line = line_iter and line_iter()
+ if output_pipe then output_pipe:close() end
+ return line
+end
+local git_command1 = [[git log --pretty=format:"%h %ai" -1]]
+local git_command2 = [[if git diff --quiet HEAD ; then echo clean ; else echo dirty ; fi]]
+function git_status()
+ local status = command_output(git_command1)
+ if status then
+ tex.tprint({luatexbase.catcodetables.CatcodeTableLaTeX, string.char(0x5c).."texttt{"}, {-2,status}, {luatexbase.catcodetables.CatcodeTableLaTeX, "}"})
+ if not (command_output(git_command2) == "clean") then tex.sprint(-2, " (dirty)") end
+ else
+ tex.sprint(-2, "?")
+ end
+end
+}
+\catcode`\%=14
+\def\showgitstatus{\directlua{git_status()}}
+
+%%
%% Paramétrages divers
%%
\setcounter{tocdepth}{2}