1 |
commit: 0ce392fe023c489a1834a25e1fbf7dc406f86a0c |
2 |
Author: Ulrich Müller <ulm <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Feb 19 18:55:09 2018 +0000 |
4 |
Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri May 4 20:07:12 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/pms.git/commit/?id=0ce392fe |
7 |
|
8 |
Change from vc to gitinfo2 for git metadata. |
9 |
|
10 |
The gitinfo2 package is included with TeXLive, has better support for |
11 |
git (e.g., information about branches and tags), and doesn't need any |
12 |
local scripts in the repository itself. |
13 |
|
14 |
.gitignore | 2 +- |
15 |
Makefile | 44 +++++++++++++++++---------- |
16 |
eapi-cheatsheet.tex | 12 ++++---- |
17 |
pms.cls | 25 ++++++++-------- |
18 |
vc | 24 --------------- |
19 |
vc-git.awk | 85 ----------------------------------------------------- |
20 |
6 files changed, 47 insertions(+), 145 deletions(-) |
21 |
|
22 |
diff --git a/.gitignore b/.gitignore |
23 |
index 6d150b7..583b6ae 100644 |
24 |
--- a/.gitignore |
25 |
+++ b/.gitignore |
26 |
@@ -5,6 +5,7 @@ |
27 |
*.blg |
28 |
*.css |
29 |
*.dvi |
30 |
+*.gin |
31 |
*.html |
32 |
*.idv |
33 |
*.lg |
34 |
@@ -18,7 +19,6 @@ |
35 |
*.tmp |
36 |
*.toc |
37 |
*.xref |
38 |
-vc.tex |
39 |
|
40 |
# Emacs backup files and locks |
41 |
*~ |
42 |
|
43 |
diff --git a/Makefile b/Makefile |
44 |
index d10a65a..5359342 100644 |
45 |
--- a/Makefile |
46 |
+++ b/Makefile |
47 |
@@ -1,5 +1,6 @@ |
48 |
-LATEXFILES := $(filter-out vc.tex,$(wildcard *.tex)) pms.cls |
49 |
-SOURCES = $(LATEXFILES) pms.bib vc vc-git.awk Makefile |
50 |
+LATEXFILES := $(wildcard *.tex) pms.cls |
51 |
+SOURCES = $(LATEXFILES) pms.bib Makefile |
52 |
+COMMITINFO = gitHeadLocal.gin |
53 |
|
54 |
TWOSIDE = |
55 |
|
56 |
@@ -10,7 +11,7 @@ all: pms.pdf |
57 |
|
58 |
html: pms.html |
59 |
|
60 |
-pms.pdf eapi-cheatsheet.pdf: $(LATEXFILES) pms.bbl vc.tex |
61 |
+pms.pdf eapi-cheatsheet.pdf: $(LATEXFILES) pms.bbl $(COMMITINFO) |
62 |
$(aux-clean) |
63 |
set -e; \ |
64 |
while true; do \ |
65 |
@@ -32,7 +33,7 @@ eapi-cheatsheet-nocombine.pdf: pms.pdf |
66 |
grep -q 'Warning.*Rerun' eapi-cheatsheet-nocombine.log || break; \ |
67 |
done |
68 |
|
69 |
-pms.dvi: $(LATEXFILES) pms.bbl vc.tex |
70 |
+pms.dvi: $(LATEXFILES) pms.bbl $(COMMITINFO) |
71 |
$(aux-clean) |
72 |
set -e; \ |
73 |
while true; do \ |
74 |
@@ -40,7 +41,7 @@ pms.dvi: $(LATEXFILES) pms.bbl vc.tex |
75 |
grep -q 'Warning.*Rerun' pms.log || break; \ |
76 |
done |
77 |
|
78 |
-pms.html: $(LATEXFILES) pms.bbl vc.tex |
79 |
+pms.html: $(LATEXFILES) pms.bbl $(COMMITINFO) |
80 |
set -e; sum=''; \ |
81 |
while true; do \ |
82 |
mk4ht xhlatex pms xhtml,fn-in; \ |
83 |
@@ -58,26 +59,37 @@ pms.html: $(LATEXFILES) pms.bbl vc.tex |
84 |
@# remove redundant span elements |
85 |
LC_ALL=C sed -i -e ':x;/<span\(\s\+[^>]*\)\?$$/{N;bx;};:y;s/\(<span\s\+[^>]*>\)\([^<]*\)<\/span>\1/\1\2/;ty' $@ |
86 |
|
87 |
-pms.bbl: pms.bib $(LATEXFILES) vc.tex |
88 |
+pms.bbl: pms.bib $(LATEXFILES) $(COMMITINFO) |
89 |
$(aux-clean) |
90 |
latex pms |
91 |
bibtex pms |
92 |
|
93 |
-vc.tex: $(SOURCES) |
94 |
- /bin/sh ./vc -m |
95 |
- |
96 |
-dist: $(SOURCES) vc.tex pms.pdf pms.html |
97 |
+$(COMMITINFO): $(SOURCES) |
98 |
+ @# see gitinfo2 documentation |
99 |
+ reltag=$$(git describe --tags --long --always --dirty='-*' \ |
100 |
+ --match='eapi-*-approved*' 2>/dev/null); \ |
101 |
+ if test -n "$${reltag}"; then \ |
102 |
+ TZ=UTC git log -1 --date=short-local --decorate=short \ |
103 |
+ --pretty="format:\usepackage[%%%n shash={%h},%n\ |
104 |
+ lhash={%H},%n authname={%an},%n authemail={%ae},%n\ |
105 |
+ authsdate={%ad},%n authidate={%ai},%n authudate={%at},%n\ |
106 |
+ commname={%cn},%n commemail={%ce},%n commsdate={%cd},%n\ |
107 |
+ commidate={%ci},%n commudate={%ct},%n refnames={%d},%n\ |
108 |
+ reltag={$${reltag}}%n]{gitexinfo}%n" > $@; \ |
109 |
+ fi |
110 |
+ |
111 |
+dist: $(SOURCES) $(COMMITINFO) pms.pdf pms.html |
112 |
PV='$(PV)'; \ |
113 |
if test -z "$${PV}"; then \ |
114 |
current_eapi=$$(sed -n 's/.*CurrentEAPIIs{\(.*\)}.*/\1/p' pms.tex); \ |
115 |
- vc_date=$$(sed -n \ |
116 |
- 's/.*VCDateISO{\([0-9]*\)-\([0-9]*\)-\([0-9]*\)}.*/\1\2\3/p' \ |
117 |
- vc.tex); \ |
118 |
- PV=$${current_eapi}_p$${vc_date}; \ |
119 |
+ commit_date=$$(sed -n \ |
120 |
+ 's/.*commsdate={\([0-9]*\)-\([0-9]*\)-\([0-9]*\)}.*/\1\2\3/p' \ |
121 |
+ $(COMMITINFO)); \ |
122 |
+ PV=$${current_eapi}_p$${commit_date}; \ |
123 |
fi; \ |
124 |
echo "PV = $${PV}"; \ |
125 |
tar -cJf pms-"$${PV}".tar.xz --transform="s%^%pms-$${PV}/%" \ |
126 |
- $(SOURCES) vc.tex && \ |
127 |
+ $(SOURCES) $(COMMITINFO) && \ |
128 |
tar -cJf pms-"$${PV}"-prebuilt.tar.xz --transform="s%^%pms-$${PV}/%" \ |
129 |
pms.pdf eapi-cheatsheet.pdf pms*.html pms.css |
130 |
|
131 |
@@ -90,7 +102,7 @@ clean: |
132 |
*.lot *.out *.html *.css *.png *.4ct *.4tc *.idv *.lg *.tmp *.xref |
133 |
|
134 |
maintainer-clean: clean |
135 |
- rm -f vc.tex |
136 |
+ rm -f $(COMMITINFO) |
137 |
|
138 |
.PHONY: all html dist upload clean maintainer-clean |
139 |
|
140 |
|
141 |
diff --git a/eapi-cheatsheet.tex b/eapi-cheatsheet.tex |
142 |
index 61481d0..e785ed6 100644 |
143 |
--- a/eapi-cheatsheet.tex |
144 |
+++ b/eapi-cheatsheet.tex |
145 |
@@ -12,6 +12,7 @@ |
146 |
\usepackage[orig,english]{isodate} |
147 |
\usepackage[scaled=.90]{helvet} |
148 |
\usepackage[nohyphen]{underscore} |
149 |
+\usepackage[local]{gitinfo2} |
150 |
\newcommand{\code}[1]{\texttt{#1}} |
151 |
% This should reflect the latest approved EAPI version |
152 |
\newcommand{\version}{7.0} |
153 |
@@ -28,12 +29,11 @@ |
154 |
Ulrich Müller \\ |
155 |
\href{mailto:ulm@g.o}{ulm@g.o} |
156 |
} |
157 |
-\input{vc.tex} |
158 |
-\ifthenelse{\equal{\VCDateISO}{}} |
159 |
-{ |
160 |
- \date{Version \version{}, generated on: \\\today} |
161 |
-}{ |
162 |
- \date{Version \version\\\printdate{\VCDateISO}} |
163 |
+\date{% |
164 |
+ Version \version \\ |
165 |
+ \ifthenelse{\equal{\gitCommitterDate}{(None)}} |
166 |
+ {Generated on: \today} |
167 |
+ {\printdate{\gitCommitterDate}}% |
168 |
} |
169 |
\CutLine*{1} |
170 |
\CutLine*{3} |
171 |
|
172 |
diff --git a/pms.cls b/pms.cls |
173 |
index 66e1828..e00b4e9 100644 |
174 |
--- a/pms.cls |
175 |
+++ b/pms.cls |
176 |
@@ -25,6 +25,7 @@ |
177 |
\PassOptionsToPackage{nohyphen}{underscore} |
178 |
\PassOptionsToPackage{nottoc,notlot,notlof}{tocbibind} |
179 |
\PassOptionsToPackage{hyphens}{url} % url.sty implicitly loaded by hyperref |
180 |
+\PassOptionsToPackage{local}{gitinfo2} |
181 |
\PassOptionsToPackage{chapter}{algorithm} |
182 |
% algorithmic and algorithm to be loaded last to avoid failures |
183 |
\RequirePackage{% |
184 |
@@ -52,15 +53,13 @@ |
185 |
caption, % Extended float environment formatting |
186 |
float, % More control over float environments |
187 |
hyperref, % Support for hyperlinks |
188 |
+ gitinfo2, % Metadata from git |
189 |
algorithm, % |
190 |
algorithmic % Set algorithms |
191 |
} |
192 |
} |
193 |
\ClassInfo{pms}{Capsulation of LaTeX stuff for the Package Manager |
194 |
Specification, loaded baseclass: \ClassToLoad\MessageBreak} |
195 |
-% Contains information over the source control system, generated |
196 |
-% through Makefile |
197 |
-\input{vc.tex} |
198 |
|
199 |
% Make processing with TeX4HT possible |
200 |
\newboolean{TEX4HT-HACKS} |
201 |
@@ -160,16 +159,16 @@ |
202 |
} |
203 |
% Reads the last commit date from the Git repository and even succeeds |
204 |
% when none is available |
205 |
-\ifthenelse{\equal{\VCDateISO}{}} |
206 |
-{ |
207 |
- \date{Generated on: \today} |
208 |
- \newcommand{\commitinfo}{} |
209 |
-}{ |
210 |
- \date{\printdate{\VCDateISO}} |
211 |
- \newcommand{\commitinfo}{% |
212 |
- This version corresponds to commit \VCRevision |
213 |
- \ifthenelse{\VCModified=0}{}{ with local changes}. |
214 |
- } |
215 |
+\date{% |
216 |
+ \ifthenelse{\equal{\gitCommitterDate}{(None)}} |
217 |
+ {Generated on: \today} |
218 |
+ {\printdate{\gitCommitterDate}}% |
219 |
+} |
220 |
+\newcommand{\commitinfo}{% |
221 |
+ \ifthenelse{\equal{\gitCommitterDate}{(None)}}{}{% |
222 |
+ This version corresponds to commit \gitAbbrevHash |
223 |
+ \ifthenelse{\equal{\gitDirty}{}}{}{ with local changes}.% |
224 |
+ }% |
225 |
} |
226 |
|
227 |
% Set page title |
228 |
|
229 |
diff --git a/vc b/vc |
230 |
deleted file mode 100644 |
231 |
index 4ad591e..0000000 |
232 |
--- a/vc |
233 |
+++ /dev/null |
234 |
@@ -1,24 +0,0 @@ |
235 |
-#!/bin/sh |
236 |
-# This is file 'vc' from the vc bundle for TeX. |
237 |
-# The original file can be found at CTAN:support/vc. |
238 |
-# This file is Public Domain. |
239 |
- |
240 |
-# Parse command line options. |
241 |
-full=0 |
242 |
-mod=0 |
243 |
-while [ -n "$(echo $1 | grep '-')" ]; do |
244 |
- case $1 in |
245 |
- -f ) full=1 ;; |
246 |
- -m ) mod=1 ;; |
247 |
- * ) echo 'usage: vc [-f] [-m]' |
248 |
- exit 1 |
249 |
- esac |
250 |
- shift |
251 |
-done |
252 |
-# English locale. |
253 |
-LC_ALL=C |
254 |
-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 |
255 |
-if [ "$mod" = 1 ] |
256 |
-then |
257 |
- git status --porcelain |gawk -v script=status -f vc-git.awk >> vc.tex |
258 |
-fi |
259 |
|
260 |
diff --git a/vc-git.awk b/vc-git.awk |
261 |
deleted file mode 100644 |
262 |
index 8b9b052..0000000 |
263 |
--- a/vc-git.awk |
264 |
+++ /dev/null |
265 |
@@ -1,85 +0,0 @@ |
266 |
-# This is file 'vc-git.awk' from the vc bundle for TeX. |
267 |
-# The original file can be found at CTAN:support/vc. |
268 |
-# This file is Public Domain. |
269 |
-BEGIN { |
270 |
-### Process output of "git status". |
271 |
- if (script=="status") { |
272 |
- modified = 0 |
273 |
- } |
274 |
-} |
275 |
- |
276 |
- |
277 |
- |
278 |
-### Process output of "git log". |
279 |
-script=="log" && /^Hash:/ { Hash = substr($0, 2+match($0, ":")) } |
280 |
-script=="log" && /^Abr. Hash:/ { AbrHash = substr($0, 2+match($0, ":")) } |
281 |
-script=="log" && /^Parent Hashes:/ { ParentHashes = substr($0, 2+match($0, ":")) } |
282 |
-script=="log" && /^Abr. Parent Hashes:/ { AbrParentHashes = substr($0, 2+match($0, ":")) } |
283 |
-script=="log" && /^Author Name:/ { AuthorName = substr($0, 2+match($0, ":")) } |
284 |
-script=="log" && /^Author Email:/ { AuthorEmail = substr($0, 2+match($0, ":")) } |
285 |
-script=="log" && /^Author Date:/ { AuthorDate = substr($0, 2+match($0, ":")) } |
286 |
-script=="log" && /^Committer Name:/ { CommitterName = substr($0, 2+match($0, ":")) } |
287 |
-script=="log" && /^Committer Email:/ { CommitterEmail = substr($0, 2+match($0, ":")) } |
288 |
-script=="log" && /^Committer Date:/ { CommitterDate = substr($0, 2+match($0, ":")) } |
289 |
- |
290 |
-### Process output of "git status". |
291 |
-### Changed index? |
292 |
-script=="status" && /^[MADRC]/ { if (modified == 0) modified = 1 } |
293 |
-### Unstaged modifications? |
294 |
-script=="status" && /^.[MD]/ { modified = 2 } |
295 |
- |
296 |
- |
297 |
- |
298 |
-END { |
299 |
-### Process output of "git log". |
300 |
- if (script=="log") { |
301 |
-### Standard encoding is UTF-8. |
302 |
- if (Encoding == "") Encoding = "UTF-8" |
303 |
-### Extract relevant information from variables. |
304 |
- LongDate = substr(CommitterDate, 1, 25) |
305 |
- DateRAW = substr(LongDate, 1, 10) |
306 |
- DateISO = DateRAW |
307 |
- DateTEX = DateISO |
308 |
- gsub("-", "/", DateTEX) |
309 |
- Time = substr(LongDate, 12, 14) |
310 |
-### Write file identification to vc.tex. |
311 |
- print "%%% This file has been generated by the vc bundle for TeX." |
312 |
- print "%%% Do not edit this file!" |
313 |
- print "%%%" |
314 |
-### Write Git specific macros. |
315 |
- print "%%% Define Git specific macros." |
316 |
- print "\\gdef\\GITHash{" Hash "}%" |
317 |
- print "\\gdef\\GITAbrHash{" AbrHash "}%" |
318 |
- print "\\gdef\\GITParentHashes{" ParentHashes "}%" |
319 |
- print "\\gdef\\GITAbrParentHashes{" AbrParentHashes "}%" |
320 |
- print "\\gdef\\GITAuthorName{" AuthorName "}%" |
321 |
- print "\\gdef\\GITAuthorEmail{" AuthorEmail "}%" |
322 |
- print "\\gdef\\GITAuthorDate{" AuthorDate "}%" |
323 |
- print "\\gdef\\GITCommitterName{" CommitterName "}%" |
324 |
- print "\\gdef\\GITCommitterEmail{" CommitterEmail "}%" |
325 |
- print "\\gdef\\GITCommitterDate{" CommitterDate "}%" |
326 |
-### Write generic version control macros. |
327 |
- print "%%% Define generic version control macros." |
328 |
- print "\\gdef\\VCRevision{\\GITAbrHash}%" |
329 |
- print "\\gdef\\VCAuthor{\\GITAuthorName}%" |
330 |
- print "\\gdef\\VCDateRAW{" DateRAW "}%" |
331 |
- print "\\gdef\\VCDateISO{" DateISO "}%" |
332 |
- print "\\gdef\\VCDateTEX{" DateTEX "}%" |
333 |
- print "\\gdef\\VCTime{" Time "}%" |
334 |
- print "\\gdef\\VCModifiedText{\\textcolor{red}{with local modifications!}}%" |
335 |
- print "%%% Assume clean working copy." |
336 |
- print "\\gdef\\VCModified{0}%" |
337 |
- print "\\gdef\\VCRevisionMod{\\VCRevision}%" |
338 |
- } |
339 |
- |
340 |
-### Process output of "git status". |
341 |
- if (script=="status") { |
342 |
- print "%%% Is working copy modified?" |
343 |
- print "\\gdef\\VCModified{" modified "}%" |
344 |
- if (modified==0) { |
345 |
- print "\\gdef\\VCRevisionMod{\\VCRevision}%" |
346 |
- } else { |
347 |
- print "\\gdef\\VCRevisionMod{\\VCRevision~\\VCModifiedText}%" |
348 |
- } |
349 |
- } |
350 |
-} |