I'm using the rubber program (in Python, from Lauchpad) to process a LaTeX document (thru pdflatex called by rubber -d) on Debian/Sid/Linux (the document is some H2020 European R&D proposal). I have the version 1.4-2 of that rubber package.

The LaTeX document and its directory is versionned using git.

I want to have a LaTeX command there which gives the current git commit id, to be able to show that id in the generated PDF file.

When I run the following shell command in my terminal :

printf '\\newcommand{\\cgitcommitid}{%s}\n' $(git log --format=oneline --abbrev=16 --abbrev-commit -q | cut '-d ' -f1 | head -1)

It gives me the expected output:


so I would like to generate that in some cgit-gitcommitid.tex generated file.

I have the following cgit-rubber-rules.ini file:

; This is our extra rules cgit-rubber-rules.ini file for Rubber
; Rubber is a LaTeX driver in Python
; see https://launchpad.net/rubber

;; SVG figures produced by InkScape (see http://inkscape.org/ for more)
;; convert to PDF
target = (.*)\.pdf
source = \1.svg
cost = 4
rule = shell
command = inkscape --without-gui --export-pdf=$target $source

;; convert to EPS

target = (.*)\.eps
source = \1.svg
cost = 4
rule = shell
command = inkscape --without-gui --export-eps=$target $source

target = cgit-gitcommitid\.tex
;source = \.git
cost = 3
rule = shell
command = printf '\\newcommand{\\cgitcommitid}{%s}\n' $(git log --format=oneline --abbrev=16 --abbrev-commit -q | cut '-d ' -f1 | head -1) > cgit-gitcommitid.tex

My cgitprop.tex main LaTeX file has:

 % file cgitprop.tex


 % rubber: module pdftex
 % rubber: module graphics
 % rubber: rules cgit-rubber-rules.ini

 % rubber: clean cgit-gitcommitid.tex
 % rubber: make cgit-gitcommitid.tex with cgit-gitcommitid-make from .git
 % rubber: watch cgit-gitcommitid.tex

But when I run rubber -v -v -d cgitprop the cgit-gitcommitid.tex file is not generated:

   rubber -v -v -d cgitprop
  This is Rubber version 1.4.
  [latex] directive: module pdftex
  [latex] built-in module pdftex registered
  [latex] parsing /ssdhome/basile/CGIT2017FET/cgitprop.tex
  [latex] script module article registered
  [latex] built-in module graphicx registered
  [latex] directive: produce cgitprop.out cgitprop.brf
  [latex] directive: watch cgitprop.out
  [latex] script module hyperref registered
  [latex] directive: module pdftex
  [latex] directive: module graphics
  [latex] built-in module graphics registered
  [latex] directive: rules cgit-rubber-rules.ini
  [latex] directive: clean cgit-gitcommitid.tex
  [latex] directive: make cgit-gitcommitid.tex with cgit-gitcommitid-make from .git
  [latex] directive: watch cgit-gitcommitid.tex

and later

  [leaf] 'cgit-gitcommitid.tex' does not exist

What am I doing wrong? Why isn't cgit-gitcommitid.tex properly generated? Uncommenting the ;source = \.git line -by removing the initial semicolon- in my cgit-rubber-rules.ini file does not change anything.

Or do you know any LaTeX package available on Debian to generate the git information -the commit id-?

also asked on launchpad & quora

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.