[Tex/LaTex] How to a Git tag be aligned with the formatted PDF using gitinfo2

gitgitinfo

I think I do not understand the workflow of the gitinfo2 package correctly.
The documentation says (shortend):

  1. Edit and format abc.tex until ready for release
  2. Commit the release version of abc.tex
  3. Tag the release
  4. checkout abc.pdf
  5. Format & commit the release version of abc.pdf

My question: How can the Git tag be aligned with the formatted PDF? The described workflow is showing two commits… When I am following it, the given tag in the commit history is "one behind". As consequence: when checking out the version where the tag is given, the PDF does not contain the tag.

I do not see different behaviour when using smartgit or commandline tool git.

Is this supposed to be? Can somebody help me?

Thank you,

Thomas

Edit: Added picture to specify my question.

As shown in the screenshot (graphical log view of Smartgit) the commit where the tag is given and the commit where the pdf was added – containing the right release info – are not identical. –> When checking out "Release 1.34" the PDF has not the right info. Only the following commit contains a correct set of data.
The commit with the pdf containing the right Release info is not the same like the one where the tag was added.

Edit 2:

As current workaround I am moving the tag after the PDF commit as described in this post.

Best Answer

The main assumption is that abc.pdf is being tracked by git.

Here is a list of command line steps, that keeps the release number up to date (this assumes that abc.pdf has been committed at some point previously)

(start with clean repo, make changes to abc.tex and compile)

git add abc.tex
git commit -m "my commit message goes here"
git tag -a 1.34
git checkout abc.pdf
pdflatex  abc
git add abc.pdf
git commit -m "updated release number in pdf"

Here is the file I have used for abc.tex

\documentclass{article}
\usepackage[mark,grumpy]{gitinfo2}

% gitinfo2 settings
\renewcommand{\gitMark}{Release: \gitRel}

\begin{document}
hello world
\end{document}

One reason your release tag might not be as you intend could be because it isn't being picked up by

RELTAG=$(git describe --tags --long --always --dirty='-*' --match '[0-9]*.*' 2>/dev/null)` in the `.git/hooks/post-.*

files. If your tag starts with anything other than a number, then you need to change the --match part accordingly. For example, if your tag starts with a V, as in V3.2.2, then you might use

RELTAG=$(git describe --tags --long --always --dirty='-*' --match 'V[0-9]*.*' 2>/dev/null)` in the `.git/hooks/post-.*
Related Question