Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
\#*
auto/
*/.auxfiles/
sandbox/
build/
gitHeadInfo.gin
tugboat/tugboat.bib
Expand Down
6 changes: 6 additions & 0 deletions .gitlab-ci.yml.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
compile_pdf:
script:
- latexmk -cd -e -f -pdf -view=none "main.tex"
artifacts:
paths:
- main.pdf
2 changes: 2 additions & 0 deletions .latexmkrc.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# gitinfo2
system("gitinfo2 -c CI_BUILD_REF_NAME");
11 changes: 6 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ git = git
silent =
include ~/.make/Makefile

archive = gitinfo2.tar.gz
pkg = gitinfo2
archive = $(pkg).tar.gz
ginfile = .git/gitHeadInfo.gin
pseudofile = gitHeadLocal.gin

codelist = gitinfo2.sty gitexinfo.sty
docslist = gitinfo2.tex gitinfo2.pdf $(pseudofile)
codelist = $(pkg).sty gitexinfo.sty
docslist = $(pkg).tex $(pkg).pdf $(pseudofile)
morelist = gitinfotest.tex post-xxx-sample.txt README
dirtlist = gitinfo2.pdf gitinfo2.tar.gz $(pseudofile)
dirtlist = $(pkg).pdf $(pkg).tar.gz $(pseudofile)

list = $(codelist) $(docslist) $(morelist)

Expand All @@ -34,7 +35,7 @@ $(archive): $(list)
clean $(ginfile):
$(git) checkout $(dirtlist)

gitinfo2.pdf: gitinfo2.tex $(pseudofile)
$(pkg).pdf: $(pkg).tex $(codelist) $(pseudofile)
rm -f $@ $(auxdir)/$@
$(lmkexec) -outdir=$(auxdir) $(silent) -xelatex -e '$$makeindex=q/makeindex %O -s blindex.ist -o %D %S/' "$<"
chmod a+rw $(auxdir) $(auxdir)/*
Expand Down
9 changes: 6 additions & 3 deletions gitexinfo.sty
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
\DeclareStringOption{commsdate}
\DeclareStringOption{commidate}
\DeclareStringOption{commudate}
\DeclareStringOption{currbranch}
\DeclareStringOption{refnames}
\DeclareStringOption{firsttagdescribe}
\DeclareStringOption{reltag}
Expand All @@ -48,6 +49,7 @@
\renewcommand{\gitCommitterDate}{\gitInf@commsdate}
\renewcommand{\gitCommitterIsoDate}{\gitInf@commidate}
\renewcommand{\gitCommitterUnixDate}{\gitInf@commudate}
\renewcommand{\gitCurrBranch}{\gitInf@currbranch}
\renewcommand{\gitFirstTagDescribe}{\detokenize\expandafter{\gitInf@firsttagdescribe}}
\renewcommand{\gitReferences}{\detokenize\expandafter{\gitInf@refnames}}
\newcommand{\git@vtag}[1]{%
Expand All @@ -69,9 +71,9 @@
}{}%
}%
}%
\expandafter\docsvlist\expandafter{#1}%
\StrDel{#1}{(}[\bcut]%
\StrDel{\bcut}{)}[\bcut]%
\expandafter\docsvlist\expandafter{\bcut}%
\IfSubStr{\bcut}{->}{% git version 2+?
\StrBetween{\bcut,}{HEAD -> }{,}[\bcut]% yes - no problem
}{%
Expand All @@ -81,7 +83,8 @@
\StrCut[\xcut]{\bcut}{, }{\lcut}{\bcut}% git vv < 2 - take last token
}% (not always accurate)
}
\IfEq{\bcut}{}{}{%
\IfEq{\bcut}{}{%
}{%
\IfEq{\bcut}{HEAD}{% detached head?
}{% no - we have the branch name
\renewcommand{\gitBranch}{\detokenize\expandafter{\bcut}}%
Expand Down Expand Up @@ -112,7 +115,7 @@
\StrCut[\gitInf@mcount]{\gitInf@describe}{-}{\gitInf@rel}{\gitInf@off}
\renewcommand{\gitRel}{\detokenize\expandafter{\gitInf@rel}}
\renewcommand{\gitRels}{\space\gitRel}
\renewcommand{\gitReln}{\space\gitRel}
\IfEq{\gitRel}{}{}{\renewcommand{\gitReln}{\space\gitRel}}
\renewcommand{\gitRoff}{\gitInf@off}
\renewcommand{\gitDescribe}{#1}
}%
Expand Down
17 changes: 14 additions & 3 deletions gitinfo2.sty
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@
\DeclareBoolOption{mark}
\DeclareBoolOption{markifdraft}
\DeclareBoolOption{markifdirty}
\DeclareBoolOption{markifnotmaster}
\DeclareBoolOption{marknotags}
\DeclareStringOption[(None)]{missing}
\DeclareStringOption[(None)]{notags}
\DeclareStringOption[(*)]{dirty}
\DeclareStringOption[4]{maxdepth}
\DeclareStringOption[1.5\baselineskip]{raisemark}
\DeclareStringOption[master]{master}
\ProcessKeyvalOptions*
\newcommand{\gitAbbrevHash}{\gitInf@missing}
\newcommand{\gitHash}{\gitInf@missing}
Expand All @@ -55,6 +57,7 @@
\newcommand{\gitFirstTagDescribe}{\gitInf@missing}
\newcommand{\gitReferences}{\gitInf@missing}
\newcommand{\gitBranch}{\gitInf@missing}
\newcommand{\gitCurrBranch}{\gitInf@missing}
\newcommand{\gitVtag}{}
\newcommand{\gitVtags}{}
\newcommand{\gitVtagn}{\space\gitInf@missing}
Expand Down Expand Up @@ -102,6 +105,9 @@
\GI@is@a@repo@true
\IfFileExists{./\GI@githeadinfo@file}{%
\edef\GI@repo@prefix{./}%
\PackageInfo{gitinfo2}{%
gitinfo2 found : \GI@githeadinfo@file \MessageBreak
}%
}{%
\GI@set@repo@prefix}}

Expand All @@ -117,9 +123,9 @@
\else
\edef\GI@repo@prefix{../\GI@repo@prefix}%
\IfFileExists{\GI@githeadinfo@file}{%
\PackageInfo{gitinfo2}{%
gitinfo2 found : \GI@githeadinfo@file \MessageBreak
}%
\PackageInfo{gitinfo2}{%
gitinfo2 found : \GI@githeadinfo@file \MessageBreak
}%
\GI@export@macro\GI@githeadinfo@file
}{%
\expandafter\GI@set@repo@prefix@}%
Expand Down Expand Up @@ -169,6 +175,11 @@
% ---------------------------------------------------------------------
% Watermarking
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
\ifbool{gitInf@markifnotmaster}{%
\IfStrEq{\gitCurrBranch}{\gitInf@master}{}{%
\booltrue{gitInf@mark}
}%
}{}%
\ifbool{gitInf@markifdirty}{%
\IfEq{\gitDirty}{}{}{%
\booltrue{gitInf@mark}
Expand Down
24 changes: 23 additions & 1 deletion post-xxx-sample.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,31 @@
# -----------------------------------------------------
# Post-{commit,checkout,merge} hook for the gitinfo2 package
#
while getopts ":c:" opt; do
case $opt in
c)
if [ "$OPTARG" == "CI_BUILD_REF_NAME" ]; then
CURRBRANCH=$CI_BUILD_REF_NAME
else
CURRBRANCH=$OPTARG
fi
;;
\?)
echo "unknown option: -$OPTARG"
exit 1
;;
:)
echo "Option -$OPTARG requires an argument (name of current branch)."
exit 1
;;
esac
done
# Get the first tag found in the history from the current HEAD
FIRSTTAG=$(git describe --tags --always --dirty='-*' 2>/dev/null)
# Get the first tag in history that looks like a Release
RELTAG=$(git describe --tags --long --always --dirty='-*' --match '[0-9]*.*' 2>/dev/null)
# Get the checked out branch
CURRBRANCH="${CURRBRANCH:-$( git rev-parse --abbrev-ref HEAD )}"
# Hoover up the metadata
git --no-pager log -1 --date=short --decorate=short \
--pretty=format:"\usepackage[%
Expand All @@ -27,5 +48,6 @@ git --no-pager log -1 --date=short --decorate=short \
commudate={%ct},
refnames={%d},
firsttagdescribe={$FIRSTTAG},
reltag={$RELTAG}
reltag={$RELTAG},
currbranch={$CURRBRANCH}
]{gitexinfo}" HEAD > .git/gitHeadInfo.gin