* [gentoo-pms] [PATCH] Change from vc to gitinfo2 for git metadata.
@ 2018-02-19 18:55 Ulrich Müller
0 siblings, 0 replies; only message in thread
From: Ulrich Müller @ 2018-02-19 18:55 UTC (permalink / raw
To: gentoo-pms
[-- Attachment #1: Type: text/plain, Size: 11145 bytes --]
The vc bundle is not included with TeXLive, unmaintained upstream
(last release in 2008), and local modifications keep accumulating.
---
.gitignore | 2 +-
Makefile | 40 +++++++++++++--------
eapi-cheatsheet.tex | 6 ++--
pms.cls | 15 ++++----
vc | 24 -------------
vc-git.awk | 85 ---------------------------------------------
6 files changed, 38 insertions(+), 134 deletions(-)
delete mode 100644 vc
delete mode 100644 vc-git.awk
diff --git a/.gitignore b/.gitignore
index 6d150b7..cb749b5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,7 +18,7 @@
*.tmp
*.toc
*.xref
-vc.tex
+gitHeadLocal.gin
# Emacs backup files and locks
*~
diff --git a/Makefile b/Makefile
index d10a65a..e68b6e4 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,6 @@
-LATEXFILES := $(filter-out vc.tex,$(wildcard *.tex)) pms.cls
-SOURCES = $(LATEXFILES) pms.bib vc vc-git.awk Makefile
+LATEXFILES := $(wildcard *.tex) pms.cls
+SOURCES = $(LATEXFILES) pms.bib Makefile
+COMMITINFO = gitHeadLocal.gin
TWOSIDE =
@@ -10,7 +11,7 @@ all: pms.pdf
html: pms.html
-pms.pdf eapi-cheatsheet.pdf: $(LATEXFILES) pms.bbl vc.tex
+pms.pdf eapi-cheatsheet.pdf: $(LATEXFILES) pms.bbl $(COMMITINFO)
$(aux-clean)
set -e; \
while true; do \
@@ -32,7 +33,7 @@ eapi-cheatsheet-nocombine.pdf: pms.pdf
grep -q 'Warning.*Rerun' eapi-cheatsheet-nocombine.log || break; \
done
-pms.dvi: $(LATEXFILES) pms.bbl vc.tex
+pms.dvi: $(LATEXFILES) pms.bbl $(COMMITINFO)
$(aux-clean)
set -e; \
while true; do \
@@ -40,7 +41,7 @@ pms.dvi: $(LATEXFILES) pms.bbl vc.tex
grep -q 'Warning.*Rerun' pms.log || break; \
done
-pms.html: $(LATEXFILES) pms.bbl vc.tex
+pms.html: $(LATEXFILES) pms.bbl $(COMMITINFO)
set -e; sum=''; \
while true; do \
mk4ht xhlatex pms xhtml,fn-in; \
@@ -58,26 +59,37 @@ pms.html: $(LATEXFILES) pms.bbl vc.tex
@# remove redundant span elements
LC_ALL=C sed -i -e ':x;/<span\(\s\+[^>]*\)\?$$/{N;bx;};:y;s/\(<span\s\+[^>]*>\)\([^<]*\)<\/span>\1/\1\2/;ty' $@
-pms.bbl: pms.bib $(LATEXFILES) vc.tex
+pms.bbl: pms.bib $(LATEXFILES) $(COMMITINFO)
$(aux-clean)
latex pms
bibtex pms
-vc.tex: $(SOURCES)
- /bin/sh ./vc -m
-
-dist: $(SOURCES) vc.tex pms.pdf pms.html
+$(COMMITINFO): $(SOURCES)
+ @# see documentation of gitinfo2.sty
+ reltag=$$(git describe --tags --long --always --dirty='-*' \
+ --match='eapi-*-approved*' 2>/dev/null); \
+ if test -n "$${reltag}"; then \
+ TZ=UTC git log -1 --date=short-local --decorate=short \
+ --pretty="format:\usepackage[%%%n shash={%h},%n lhash={%H},%n\
+ authname={%an},%n authemail={%ae},%n authsdate={%ad},%n\
+ authidate={%ai},%n authudate={%at},%n commname={%cn},%n\
+ commemail={%ce},%n commsdate={%cd},%n commidate={%ci},%n\
+ commudate={%ct},%n refnames={%d},%n reltag={$${reltag}}%n\
+ ]{gitexinfo}%n" > $@; \
+ fi
+
+dist: $(SOURCES) $(COMMITINFO) pms.pdf pms.html
PV='$(PV)'; \
if test -z "$${PV}"; then \
current_eapi=$$(sed -n 's/.*CurrentEAPIIs{\(.*\)}.*/\1/p' pms.tex); \
vc_date=$$(sed -n \
- 's/.*VCDateISO{\([0-9]*\)-\([0-9]*\)-\([0-9]*\)}.*/\1\2\3/p' \
- vc.tex); \
+ 's/.*commsdate={\([0-9]*\)-\([0-9]*\)-\([0-9]*\)}.*/\1\2\3/p' \
+ $(COMMITINFO)); \
PV=$${current_eapi}_p$${vc_date}; \
fi; \
echo "PV = $${PV}"; \
tar -cJf pms-"$${PV}".tar.xz --transform="s%^%pms-$${PV}/%" \
- $(SOURCES) vc.tex && \
+ $(SOURCES) $(COMMITINFO) && \
tar -cJf pms-"$${PV}"-prebuilt.tar.xz --transform="s%^%pms-$${PV}/%" \
pms.pdf eapi-cheatsheet.pdf pms*.html pms.css
@@ -90,7 +102,7 @@ clean:
*.lot *.out *.html *.css *.png *.4ct *.4tc *.idv *.lg *.tmp *.xref
maintainer-clean: clean
- rm -f vc.tex
+ rm -f $(COMMITINFO)
.PHONY: all html dist upload clean maintainer-clean
diff --git a/eapi-cheatsheet.tex b/eapi-cheatsheet.tex
index 61481d0..038d7ab 100644
--- a/eapi-cheatsheet.tex
+++ b/eapi-cheatsheet.tex
@@ -10,6 +10,7 @@
courier
}
\usepackage[orig,english]{isodate}
+\usepackage[local]{gitinfo2}
\usepackage[scaled=.90]{helvet}
\usepackage[nohyphen]{underscore}
\newcommand{\code}[1]{\texttt{#1}}
@@ -28,12 +29,11 @@
Ulrich Müller \\
\href{mailto:ulm@gentoo.org}{ulm@gentoo.org}
}
-\input{vc.tex}
-\ifthenelse{\equal{\VCDateISO}{}}
+\ifthenelse{\equal{\gitCommitterDate}{(None)}}
{
\date{Version \version{}, generated on: \\\today}
}{
- \date{Version \version\\\printdate{\VCDateISO}}
+ \date{Version \version\\\printdate{\gitCommitterDate}}
}
\CutLine*{1}
\CutLine*{3}
diff --git a/pms.cls b/pms.cls
index 66e1828..2b45029 100644
--- a/pms.cls
+++ b/pms.cls
@@ -12,6 +12,7 @@
\LoadClass{\ClassToLoad}
\PassOptionsToPackage{T1}{fontenc}
\PassOptionsToPackage{orig,english}{isodate}
+\PassOptionsToPackage{local}{gitinfo2}
% Dimensions of the text area. Define a narrow left margin to make
% room for margin notes in the right (outer) margin
\PassOptionsToPackage{textwidth=400pt,textheight=700pt,
@@ -30,6 +31,7 @@
\RequirePackage{%
fontenc, % Load extended font sets
isodate, % Date formatting and conversions
+ gitinfo2, % Metadata from git
geometry, % Set page layout
inputenc, % Allow input methods apart from ASCII
booktabs, % Nicer formatting of tables
@@ -58,9 +60,6 @@
}
\ClassInfo{pms}{Capsulation of LaTeX stuff for the Package Manager
Specification, loaded baseclass: \ClassToLoad\MessageBreak}
-% Contains information over the source control system, generated
-% through Makefile
-\input{vc.tex}
% Make processing with TeX4HT possible
\newboolean{TEX4HT-HACKS}
@@ -160,15 +159,17 @@
}
% Reads the last commit date from the Git repository and even succeeds
% when none is available
-\ifthenelse{\equal{\VCDateISO}{}}
+\ifthenelse{\equal{\gitCommitterDate}{(None)}}
{
\date{Generated on: \today}
\newcommand{\commitinfo}{}
}{
- \date{\printdate{\VCDateISO}}
+ \date{\printdate{\gitCommitterDate}}
\newcommand{\commitinfo}{%
- This version corresponds to commit \VCRevision
- \ifthenelse{\VCModified=0}{}{ with local changes}.
+ This version corresponds to commit \gitAbbrevHash
+ \ifthenelse{\equal{\gitBranch}{\detokenize{master}}}{}%
+ { on branch \gitBranch}%
+ \ifthenelse{\equal{\gitDirty}{}}{}{ with local changes}.%
}
}
diff --git a/vc b/vc
deleted file mode 100644
index 4ad591e..0000000
--- a/vc
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/sh
-# This is file 'vc' from the vc bundle for TeX.
-# The original file can be found at CTAN:support/vc.
-# This file is Public Domain.
-
-# Parse command line options.
-full=0
-mod=0
-while [ -n "$(echo $1 | grep '-')" ]; do
- case $1 in
- -f ) full=1 ;;
- -m ) mod=1 ;;
- * ) echo 'usage: vc [-f] [-m]'
- exit 1
- esac
- shift
-done
-# English locale.
-LC_ALL=C
-TZ=UTC git --no-pager log -1 HEAD --pretty=format:"Hash: %H%nAbr. Hash: %h%nParent Hashes: %P%nAbr. Parent Hashes: %p%nAuthor Name: %an%nAuthor Email: %ae%nAuthor Date: %ad%nCommitter Name: %cn%nCommitter Email: %ce%nCommitter Date: %cd%n" --date=iso-local | gawk -v script=log -v full=$full -f vc-git.awk > vc.tex
-if [ "$mod" = 1 ]
-then
- git status --porcelain |gawk -v script=status -f vc-git.awk >> vc.tex
-fi
diff --git a/vc-git.awk b/vc-git.awk
deleted file mode 100644
index 8b9b052..0000000
--- a/vc-git.awk
+++ /dev/null
@@ -1,85 +0,0 @@
-# This is file 'vc-git.awk' from the vc bundle for TeX.
-# The original file can be found at CTAN:support/vc.
-# This file is Public Domain.
-BEGIN {
-### Process output of "git status".
- if (script=="status") {
- modified = 0
- }
-}
-
-
-
-### Process output of "git log".
-script=="log" && /^Hash:/ { Hash = substr($0, 2+match($0, ":")) }
-script=="log" && /^Abr. Hash:/ { AbrHash = substr($0, 2+match($0, ":")) }
-script=="log" && /^Parent Hashes:/ { ParentHashes = substr($0, 2+match($0, ":")) }
-script=="log" && /^Abr. Parent Hashes:/ { AbrParentHashes = substr($0, 2+match($0, ":")) }
-script=="log" && /^Author Name:/ { AuthorName = substr($0, 2+match($0, ":")) }
-script=="log" && /^Author Email:/ { AuthorEmail = substr($0, 2+match($0, ":")) }
-script=="log" && /^Author Date:/ { AuthorDate = substr($0, 2+match($0, ":")) }
-script=="log" && /^Committer Name:/ { CommitterName = substr($0, 2+match($0, ":")) }
-script=="log" && /^Committer Email:/ { CommitterEmail = substr($0, 2+match($0, ":")) }
-script=="log" && /^Committer Date:/ { CommitterDate = substr($0, 2+match($0, ":")) }
-
-### Process output of "git status".
-### Changed index?
-script=="status" && /^[MADRC]/ { if (modified == 0) modified = 1 }
-### Unstaged modifications?
-script=="status" && /^.[MD]/ { modified = 2 }
-
-
-
-END {
-### Process output of "git log".
- if (script=="log") {
-### Standard encoding is UTF-8.
- if (Encoding == "") Encoding = "UTF-8"
-### Extract relevant information from variables.
- LongDate = substr(CommitterDate, 1, 25)
- DateRAW = substr(LongDate, 1, 10)
- DateISO = DateRAW
- DateTEX = DateISO
- gsub("-", "/", DateTEX)
- Time = substr(LongDate, 12, 14)
-### Write file identification to vc.tex.
- print "%%% This file has been generated by the vc bundle for TeX."
- print "%%% Do not edit this file!"
- print "%%%"
-### Write Git specific macros.
- print "%%% Define Git specific macros."
- print "\\gdef\\GITHash{" Hash "}%"
- print "\\gdef\\GITAbrHash{" AbrHash "}%"
- print "\\gdef\\GITParentHashes{" ParentHashes "}%"
- print "\\gdef\\GITAbrParentHashes{" AbrParentHashes "}%"
- print "\\gdef\\GITAuthorName{" AuthorName "}%"
- print "\\gdef\\GITAuthorEmail{" AuthorEmail "}%"
- print "\\gdef\\GITAuthorDate{" AuthorDate "}%"
- print "\\gdef\\GITCommitterName{" CommitterName "}%"
- print "\\gdef\\GITCommitterEmail{" CommitterEmail "}%"
- print "\\gdef\\GITCommitterDate{" CommitterDate "}%"
-### Write generic version control macros.
- print "%%% Define generic version control macros."
- print "\\gdef\\VCRevision{\\GITAbrHash}%"
- print "\\gdef\\VCAuthor{\\GITAuthorName}%"
- print "\\gdef\\VCDateRAW{" DateRAW "}%"
- print "\\gdef\\VCDateISO{" DateISO "}%"
- print "\\gdef\\VCDateTEX{" DateTEX "}%"
- print "\\gdef\\VCTime{" Time "}%"
- print "\\gdef\\VCModifiedText{\\textcolor{red}{with local modifications!}}%"
- print "%%% Assume clean working copy."
- print "\\gdef\\VCModified{0}%"
- print "\\gdef\\VCRevisionMod{\\VCRevision}%"
- }
-
-### Process output of "git status".
- if (script=="status") {
- print "%%% Is working copy modified?"
- print "\\gdef\\VCModified{" modified "}%"
- if (modified==0) {
- print "\\gdef\\VCRevisionMod{\\VCRevision}%"
- } else {
- print "\\gdef\\VCRevisionMod{\\VCRevision~\\VCModifiedText}%"
- }
- }
-}
--
2.17.0
[-- Attachment #2: Type: application/pgp-signature, Size: 490 bytes --]
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2018-05-01 9:48 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-19 18:55 [gentoo-pms] [PATCH] Change from vc to gitinfo2 for git metadata Ulrich Müller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox