Skip to content

Commit 6bd7815

Browse files
committed
Test update and time macros cleanup.
1 parent 5040ec6 commit 6bd7815

File tree

3 files changed

+39
-28
lines changed

3 files changed

+39
-28
lines changed

git-info.sty

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,13 @@
126126
\GI@get@branch
127127
\GI@get@head@hash
128128
\GI@get@head@infos
129-
\GI@get@gen@datetime{head}%
129+
\GI@compute@datetime
130130
\edef\@tempa{\endgroup
131131
\GI@set@export\GI@@@head@commit{\GI@head@commit}%
132132
\GI@set@export\GI@@@head@branch{\GI@head@branch}%
133133
\GI@set@export\GI@@@head@author{\GI@head@author}%
134134
\GI@set@export\GI@@@head@mail{\GI@head@mail}%
135-
\GI@set@export\GI@@@head@datetime{\GI@head@datetime}%
135+
\GI@set@export\GI@@@head@datetime{\GI@datetime}%
136136
\GI@set@export\GI@@@head@ok{\empty}}%
137137
\@tempa}
138138

@@ -203,8 +203,8 @@
203203
\newcommand\GI@get@head@infos@end{%
204204
\closein\GI@read
205205
\edef\@tempa{\endgroup
206-
\GI@set@export\GI@head@timestamp{\GI@timestamp}%
207-
\GI@set@export\GI@head@timezone{\GI@timezone}%
206+
\GI@set@export\GI@timestamp{\GI@timestamp}%
207+
\GI@set@export\GI@timezone{\GI@timezone}%
208208
\GI@set@export\GI@head@commit{\GI@commit}%
209209
\GI@set@export\GI@head@author{\GI@name}%
210210
\GI@set@export\GI@head@mail{\GI@mail}}%
@@ -259,11 +259,11 @@
259259
\advance\count@-\GI@month@length
260260
\fi}
261261

262-
\newcommand\GI@get@gen@datetime[1]{%
262+
\newcommand\GI@compute@datetime{%
263263
\begingroup
264264
\expandafter\expandafter\expandafter
265-
\GI@parse@timezone\csname GI@#1@timezone\endcsname
266-
\count@\numexpr\csname GI@#1@timestamp\endcsname
265+
\GI@parse@timezone\csname GI@timezone\endcsname
266+
\count@\numexpr\csname GI@timestamp\endcsname
267267
\GI@tzsign((\GI@tzhour*60+\GI@tzmin)*60)\relax
268268
\GI@extract@units\GI@sec{60}%
269269
\GI@extract@units\GI@min{60}%
@@ -275,7 +275,7 @@
275275
{\GI@two@d\GI@hour}{\GI@two@d\GI@min}{\GI@two@d\GI@sec}%
276276
{\GI@tzsign}{\GI@two@d\GI@tzhour}{\GI@two@d\GI@tzmin}}%
277277
\edef\@tempa{\endgroup
278-
\GI@set@export@name{GI@#1@datetime}{\GI@datetime}}
278+
\GI@set@export@name{GI@datetime}{\GI@datetime}}
279279
\@tempa}
280280

281281
\newcommand\GI@parse@timezone[5]{%

test/git-info.sty

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../git-info.sty

test/test-git-info.tex

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,29 @@
88
% helper-file=nosuchfile.ext
99
]{git-info}
1010

11+
\makeatletter
12+
\newcommand\stypeout[1]{%
13+
\immediate\write\@unused{#1}}
14+
\makeatother
15+
16+
\newcommand\showval[2]{%
17+
\stypeout{#2: -=|#1|=-}}
18+
\newcommand\testsec[1]{%
19+
\stypeout{^^J#1}}
20+
1121
\makeatletter
1222
\newcommand\testdate[3][+0000]{%
1323
\begingroup
14-
\def\GI@head@timestamp{#2}%
15-
\def\GI@head@timezone{#1}%
16-
\GI@get@gen@datetime{head}%
17-
\message{^^J#2#1:^^JMacro: \githeaddatetime}%
18-
\message{^^JReal: \space#3}%
24+
\def\GI@timestamp{#2}%
25+
\def\GI@timezone{#1}%
26+
\GI@compute@datetime
27+
\stypeout{#2#1:^^JMacro: \expandafter\GI@dtmac@datetime\GI@datetime}
28+
\stypeout{Real: \space#3}%
1929
\endgroup}
2030
\makeatother
2131

32+
% %% from the output of gen-test.php
33+
% \testsec{Date internal macros}
2234
% \testdate{0}{1970-01-01T00:00:00+00:00}
2335
% \testdate{2865906}{1970-02-03T04:05:06+00:00}
2436
% \testdate{31535999}{1970-12-31T23:59:59+00:00}
@@ -31,15 +43,14 @@
3143
% \testdate{983404799}{2001-02-28T23:59:59+00:00}
3244
% \testdate{983404800}{2001-03-01T00:00:00+00:00}
3345

34-
\newcommand\showval[2]{%
35-
\message{^^J#2: -=|#1|=-^^J}}
36-
37-
\showval{\gitinfo{@head}{commit}} {Git head commit}
38-
\showval{\gitinfo{@head}{branch}} {Git head branch}
39-
\showval{\gitinfo{@head}{author}} {Git head author}
40-
\showval{\gitinfo{@head}{mail}} {Git head mail}
41-
\showval{\gitinfo{@head}{dt@datetime}} {Git head datetime}
46+
% \testsec{Basic head info}
47+
% \showval{\gitinfo{@head}{commit}} {Git head commit}
48+
% \showval{\gitinfo{@head}{branch}} {Git head branch}
49+
% \showval{\gitinfo{@head}{author}} {Git head author}
50+
% \showval{\gitinfo{@head}{mail}} {Git head mail}
51+
% \showval{\gitinfo{@head}{dt@datetime}} {Git head datetime}
4252

53+
% \testsec{Default date formats -- head -- normal catcodes}
4354
% \showval{\gitinfo{@head}{dt@}} {Git head dt (default)}
4455
% \showval{\gitinfo{@head}{dt}} {Git head dt (empty)}
4556
% \showval{\gitinfo{@head}{dt@date}} {Git head date}
@@ -55,15 +66,14 @@
5566
% \showval{\gitinfo{@head}{dt@tzhour}} {Git head tzhour}
5667
% \showval{\gitinfo{@head}{dt@tzmin}} {Git head tzmin}
5768

58-
% dt may have catcode problems, so test also when @ is a letter
59-
%
69+
% \testsec{Default date formats -- head -- at a letter}
6070
% \makeatletter
61-
% \showval{\gitinfo{@head}{dt@datetime}} {Git head datetime (atletter)}
62-
% \showval{\gitinfo{@head}{dt@}} {Git head dt (default) (atletter)}
63-
% \showval{\gitinfo{@head}{dt}} {Git head dt (empty) (atletter)}
71+
% \showval{\gitinfo{@head}{dt@datetime}} {Git head datetime}
72+
% \showval{\gitinfo{@head}{dt@}} {Git head dt (default)}
73+
% \showval{\gitinfo{@head}{dt}} {Git head dt (empty)}
6474
% \makeatother
6575

66-
% package options
76+
% \testsec{Package options}
6777
% \makeatletter
6878
% \showval\GI@max@depth{Internal value 'maxdepth'}
6979
% \showval\GI@gih@name{Internal value 'gihname'}
@@ -72,7 +82,7 @@
7282
\begin{document}
7383

7484
% Not expandable, so must be tested in typesetting context only.
75-
% Githeadtoday: -=|\githeadtoday|=-\par
85+
% Git-head-today: -=|\gitinfo{@head}{dt@today}|=-\par
7686

7787
% Testing error messages (not expandable)
7888
% \gitinfo{@head}{commit}

0 commit comments

Comments
 (0)