From a0327e0daefa2fe35ab3e01a666f578b2b55de85 Mon Sep 17 00:00:00 2001 From: Brent Longborough Date: Sun, 22 Nov 2015 09:53:13 +0000 Subject: [PATCH 1/8] Ensure package info message (file found) issued when local option used --- gitinfo2.sty | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gitinfo2.sty b/gitinfo2.sty index 29a9491..0430709 100644 --- a/gitinfo2.sty +++ b/gitinfo2.sty @@ -102,6 +102,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}} @@ -117,9 +120,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@}% From b233acad90e77633fa73d72c15bc937502cf828f Mon Sep 17 00:00:00 2001 From: Brent Longborough Date: Sun, 22 Nov 2015 09:54:18 +0000 Subject: [PATCH 2/8] Improved structuring for a common Makefile for CTAN projects --- Makefile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index af852fb..33390f4 100644 --- a/Makefile +++ b/Makefile @@ -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) @@ -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)/* From fb264d065ecec7649e9e5ac0fa44da5db2202a6a Mon Sep 17 00:00:00 2001 From: Brent Longborough Date: Mon, 23 Nov 2015 21:09:21 +0000 Subject: [PATCH 3/8] Ignore the sandbox directory --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index e7215d5..15e47c0 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ \#* auto/ */.auxfiles/ +sandbox/ build/ gitHeadInfo.gin tugboat/tugboat.bib From 9353d478b2e980c4e0f6e54b618ac12429f44709 Mon Sep 17 00:00:00 2001 From: Brent Longborough Date: Mon, 23 Nov 2015 21:09:49 +0000 Subject: [PATCH 4/8] Fix Version and Release rendering bugs --- gitexinfo.sty | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gitexinfo.sty b/gitexinfo.sty index 0f80141..2b7e5f2 100644 --- a/gitexinfo.sty +++ b/gitexinfo.sty @@ -69,9 +69,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 }{% @@ -81,7 +81,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}}% @@ -112,7 +113,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} }% From 7dbe1fb81454ccf185fd9dd2ea2029f758cb4c6b Mon Sep 17 00:00:00 2001 From: obma Date: Sun, 31 Jul 2016 12:19:08 +0200 Subject: [PATCH 5/8] Added new functionality to watermark if not working on release-branch. New package options: - markifnotmaster: bool to enable watermarking if not on release-branch - master: string (default: master); name of the release-branch Example: \usepackage[markifnotmaster,master=publish]{gitinfo2} --- gitexinfo.sty | 2 ++ gitinfo2.sty | 8 ++++++++ post-xxx-sample.txt | 5 ++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/gitexinfo.sty b/gitexinfo.sty index 2b7e5f2..99e3408 100644 --- a/gitexinfo.sty +++ b/gitexinfo.sty @@ -32,6 +32,7 @@ \DeclareStringOption{commsdate} \DeclareStringOption{commidate} \DeclareStringOption{commudate} +\DeclareStringOption{currbranch} \DeclareStringOption{refnames} \DeclareStringOption{firsttagdescribe} \DeclareStringOption{reltag} @@ -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]{% diff --git a/gitinfo2.sty b/gitinfo2.sty index 0430709..2b3440f 100644 --- a/gitinfo2.sty +++ b/gitinfo2.sty @@ -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} @@ -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} @@ -172,6 +175,11 @@ % --------------------------------------------------------------------- % Watermarking % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +\ifbool{gitInf@markifnotmaster}{% + \IfStrEq{\gitCurrBranch}{\gitInf@master}{}{% + \booltrue{gitInf@mark} + }% +}{}% \ifbool{gitInf@markifdirty}{% \IfEq{\gitDirty}{}{}{% \booltrue{gitInf@mark} diff --git a/post-xxx-sample.txt b/post-xxx-sample.txt index d9e6ddb..3d8aa29 100644 --- a/post-xxx-sample.txt +++ b/post-xxx-sample.txt @@ -10,6 +10,8 @@ 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=$( git rev-parse --abbrev-ref HEAD ) # Hoover up the metadata git --no-pager log -1 --date=short --decorate=short \ --pretty=format:"\usepackage[% @@ -27,5 +29,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 From ba483f1ebb83e8703920961bd8ad0e453a96e153 Mon Sep 17 00:00:00 2001 From: Max Ober Date: Wed, 24 Aug 2016 01:17:31 +0200 Subject: [PATCH 6/8] Add functionality to work in gitlab build Added parameter -c to set the name of the current branch. If set to CI_BUILD_REF_NAME the environment variable CI_BUILD_REF_NAME, wich is available in GitLab CI, is used to determine the name of the current branch. --- post-xxx-sample.txt | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/post-xxx-sample.txt b/post-xxx-sample.txt index 3d8aa29..7a6c7c7 100644 --- a/post-xxx-sample.txt +++ b/post-xxx-sample.txt @@ -6,12 +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=$( git rev-parse --abbrev-ref HEAD ) +CURRBRANCH="${CURRBRANCH:-$( git rev-parse --abbrev-ref HEAD )}" # Hoover up the metadata git --no-pager log -1 --date=short --decorate=short \ --pretty=format:"\usepackage[% From 16be08a015a453818fc61eb4395aad4e4baa8f76 Mon Sep 17 00:00:00 2001 From: Max Ober Date: Wed, 24 Aug 2016 10:35:06 +0200 Subject: [PATCH 7/8] Include in latexmk Place this file in your project root named .latexmkrc or latexmkrc and use latexmk to compile. The parameter "-c CI_BUILD_REF_NAME" is only needed, if you want to enable use of gitinfo2 in gitlab automatic builds. --- .latexmkrc.example | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .latexmkrc.example diff --git a/.latexmkrc.example b/.latexmkrc.example new file mode 100644 index 0000000..ba93f9f --- /dev/null +++ b/.latexmkrc.example @@ -0,0 +1,2 @@ +# gitinfo2 +system("gitinfo2 -c CI_BUILD_REF_NAME"); From 748273812d160c9dccfedadb0845e0dd6f573bd2 Mon Sep 17 00:00:00 2001 From: Max Ober Date: Wed, 24 Aug 2016 10:38:27 +0200 Subject: [PATCH 8/8] Example for GitLab Automatic Build Having this file (named .gitlab-ci.yml) in your GitLab repository will automatically compile your project after every push and save the pdf. Adopt main.tex and main.pdf to your project. --- .gitlab-ci.yml.example | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .gitlab-ci.yml.example diff --git a/.gitlab-ci.yml.example b/.gitlab-ci.yml.example new file mode 100644 index 0000000..adb2060 --- /dev/null +++ b/.gitlab-ci.yml.example @@ -0,0 +1,6 @@ +compile_pdf: + script: + - latexmk -cd -e -f -pdf -view=none "main.tex" + artifacts: + paths: + - main.pdf