summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/gitlog/gitlog.tex
blob: 4685c420130f4bd9da31b88c51b238f1573b292d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
% gitlog.tex
% Copyright 2015 Brent Longborough
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
% The Current Maintainer of this work is Brent Longborough.
% -----------------------------------------------------
\documentclass[a4paper,12pt,twoside,openany]{memoir}
% =====================================================
\usepackage[british]{babel}
\selectlanguage{british}
\usepackage[style=iso]{datetime2}
\usepackage[local,pcount,grumpy,markifdirty]{gitinfo2}
\usepackage{tgpagella}
\usepackage{tgadventor}
\usepackage{fontspec}
\setmainfont[Numbers={Proportional,OldStyle},Ligatures=TeX]{TeX Gyre Pagella}
\setsansfont[Numbers={Proportional,OldStyle},Ligatures=TeX]{TeX Gyre Adventor}
\setmonofont{Consolas}
\usepackage{enumitem}
\setlist[description]{%
    format=\ttfamily\bfseries,
    style=nextline,
    leftmargin=3em,
    itemsep=0.5\onelineskip}
\setulmarginsandblock{0.11111\paperwidth}{0.22222\paperwidth}{*}
\setlrmarginsandblock{0.11111\paperwidth}{0.22222\paperwidth}{*}
\setheadfoot{1.2\baselineskip}{0.0849\paperwidth}
\setmarginnotes{0.125\foremargin}{0.75\foremargin}{\onelineskip}
\setheaderspaces{*}{*}{0.618}
\checkandfixthelayout[fixed]
% \makepagenote
% \continuousnotenums
% \notepageref
% \foottopagenote
% \renewcommand*{\printpageinnotes}[1]{%
%   (p.\pageref{#1})\space}
% \renewcommand\printpageinnoteshyperref[1]{%
%   (p.\pageref*{#1})\space}
% \renewcommand*{\pagenotesubhead}[3]{%
%   \subsubsection*{#1: #3}}
\tightlists
\chapterstyle{bringhurst}
\pagestyle{empty}
\aliaspagestyle{chapter}{empty}
\settocdepth{subsection}
\setsecnumdepth{none}
\newcommand{\bpara}[1]{\par\vspace{\beforeparaskip}\noindent\textbf{#1}\,}
\newcommand{\rpara}[1]{\par\noindent\textbf{#1}\,}
\newcommand{\tcmd}[1]{\texttt{\textbackslash#1}}
\newcommand{\dark}[1]{\texttt\textbf{{#1}}}
\newcommand{\sfit}[1]{\textit{#1}}
\newcommand{\git}{\sfit{git}}
\newcommand*{\emailat}{@}
\newcommand{\tpname}{\sfit{gitlog}}
\newcommand{\tpfname}{\textsf{gitlog.sty}}
% -----------------------------------------------------
\usepackage[%
	bookmarksnumbered,
	bookmarksopen,
	linktocpage,
	]{hyperref}
\hypersetup{
   pdfauthor={Brent Longborough},
   pdftitle={The gitlog package: git change logs for LaTeX},
   pdfkeywords={git;changelog;dvcs},
}
\usepackage[%
    write,
	bibfile=gitlog.sample.bib,
	github=Hightor/gitlog,
	title={Sample Git Change Log},
]{gitlog}
\begin{document}
\frontmatter
% -----------------------------------------------------
\title{%
	~\\[2\baselineskip]
	\Huge \tpfname\\[2ex]%
	\Large A proof of concept for automatic typesetting \\of change logs from the \git\ \textsc{dvcs}
	}
\author{Brent Longborough}
\date{\DTMenglishmonthname{\DTMfetchmonth{gitdate}} \DTMfetchyear{gitdate}}
\maketitle

{\centering
Release:\gitRels\ (\gitAbbrevHash)\\
}
% -----------------------------------------------------
\thispagestyle{empty}
\aliaspagestyle{chapter}{plain}
\clearforchapter
\tableofcontents*
% -----------------------------------------------------
\mainmatter
\pagestyle{giruled}
\aliaspagestyle{chapter}{giplain}
\chapter{Introduction}
The \git{} distributed version control system
maintains an historical log of update activity.
The \tpname{} package provides a way automatically 
to typeset such a log, optionally linking commits 
from the typeset log
to one of the online \textsc{dvcs} hosting services.

% - - - - - - - - - - - - - - - - - - - - - - - - - - -
\section{Limitations}

The current release (\gitRel) 
is intended only as a \emph{proof-of-concept}, 
and should not be used for production-level work
unless you're happy with these limitations:
\begin{itemize}
\item Formatting maliciously-coded documents 
\textbf{\emph{can cause arbitrary files to be overwritten.}} 
Although this problem is easy to avoid 
(and requires the \sfit{--shell-escape} command line option),
there are no built-in protections.
\item The \git\ change log is built and formatted using the 
facilities of \sfit{biblatex} and \sfit{biber}.
The way this is currently implemented makes it unlikely that 
documents using \tpname\ can contain `normal' bibliographies.
\item New lines in the \git\ change log commit messages are 
simply converted to spaces. 
The result is pretty ugly, 
unless you've had the foresight 
to punctuate your commit messages nicely.
\end{itemize}

\noindent 
That said, I think \tpname\ will still be useful to a subset of \TeX\ users,
and I welcome suggestions and contributed code via email or Github, where the url is 
\url{https://github.com/Hightor/gitlog/issues}.


% - - - - - - - - - - - - - - - - - - - - - - - - - - -
\section{How \tpname\ works}
\begin{enumerate}
\item The package uses a git command internally, via the \tcmd{write18} command,
to write out the change log in the shape of a rather strange
\sfit{.bib} file

\item The change log .bib file contains a series of items of type \sfit{gitcommit},
defined and formatted by the \tpname\ 
data model and bibliography styles which accompany the package.

\item The rest of the work is done by persuading \sfit{biblatex} and \sfit{biber}
to treat this data as a bibliography.

\item Optionally, you can generate your own `change log bibliography', 
using this command (joined up into a single line):\\[\baselineskip]
{\ttfamily
git --no-pager log --reverse --date=short\\ 
--pretty="format:@gitcommit\{\%h,\%n author = \{\%an\},\%n\\
date = \{\%ad\}, \%n title = \{\%B\}, \%n commithash = \{\%H\}\\
\}" > \textit{filename}
}

\end{enumerate}

% -----------------------------------------------------
\chapter{Using the package}
\label{ch:using}
To collect and typeset \git{} history,
you load the \tpname\ package in the usual way:\\[0.5\baselineskip]
\texttt{\textbackslash usepackage[$<options>$]\{gitlog\}}

% - - - - - - - - - - - - - - - - - - - - - - - - - - -
\section{Package options}

The following options are available:

\subsection{General options}

\begin{description}

\item[\texttt{title=\textit{log title}}]
This option allows you to change the chapter title associated with 
the typeset change log.
The default is `Change Log'.

\item[\texttt{date}, \texttt{nodate}]
These complementary options
allow you to specify whether or not you want 
the author date and name to be added to the change log.
The default is \texttt{nodate}.


\end{description}

\subsection{Options for controlling the .bib file}

\begin{description}

\item[\texttt{write}, \texttt{nowrite}]
These complementary options
allow you to specify whether or not you want 
\tpname\ to generate the special change log (\sfit{.bib}) 
for you.

If you specify \texttt{write}, then \tpname\ will regenerate the 
change log every time the document is formatted. 
Note that this option is implemented with the \tcmd{write18} command,
and requires that your document be processed with the \TeX option 
\texttt{--shell-escape}.

If you specify \texttt{nowrite}, then \tpname\ will not write anything,
and the \texttt{--shell-escape} option is not required.
However, in this case, 
you are responsible for generating the change log 
in the correct format for \tpname\ to use, 
as well as being able to hand-tailor it.

If neither option is specified, the default depends on whether or not
you use the \sfit{bibfile} option, described next.  

\clearpage
\item[\texttt{bibfile=\textit{filename}}]
The \git\ change log data is kept in 
a file in \sfit{biblatex .bib} format, 
which \tpname\ writes (if requested) and then reads 
to format the change log.

If this option is not specified, then a default filename
is used:
\textit{<jobname>}\texttt{.gitlog.bib}. 
In this case, the default option \sfit{write} is used,
but can be suppressed by specifying \texttt{nowrite}.

This can be overridden by specifying your own choice
of filename using this option.
In this case, the default option \sfit{nowrite} is used,
but you can force \tpname\ to write to your file 
by specifying \texttt{write}.

\dark{Warning:} there is \emph{no} protection against writing
to any file name whatsoever. 
The default settings are reasonably `safe'; 
where you need to ship the document without its repository,
then  
\begin{quote}
{\ttfamily
[write,bibfile=\jobname.local.bib]
}
\end{quote}
is probably a safe set of options to use.

\end{description}

\subsection{Options for linking to on-line services}

The change log typeset by \tpname\ can include links
connecting each commit to its corresponding page
in either the GitHub or the Atlassian Bitbucket 
online repository services. 
(Trade marks of their respective owners.)

To use this feature, you must load the \sfit{hyperref} package
before loading \tpname, and use one of the following, 
mutually exclusive, options.

\begin{description}

\item[\texttt{github=\textit{repository-path}}]
When each commit in the changelog is typeset,
a link is generated to the corresponding page on GitHub,
with a \textsc{url} in this format:
\begin{quote}
{\ttfamily\small
https://github.com/{\rmfamily\itshape repository-path}/commit/{\rmfamily\itshape commit-hash}
}
\end{quote}

\item[\texttt{bitbucket=\textit{repository-path}}]
When each commit in the changelog is typeset,
a link is generated to the corresponding page on Atlassian Bitbucket,
with a \textsc{url} in this format:
\begin{quote}
{\ttfamily\small
https://bitbucket.org/{\rmfamily\itshape repository-path}/commits/{\rmfamily\itshape commit-hash}
}
\end{quote}

\end{description}

\section{Typesetting the change log}

The command \tcmd{printGitLog}
typesets the change log, as a new chapter containing a pseudo-bibliography,
at that point in the document. 
At the moment, there are very few options to allow you to tailor the typography.

A sample change log can be seen at the end of this manual.

% -----------------------------------------------------
\chapter{Etc}
\section{Release notes}

\rpara{R0.0.beta: 2015-11-24}
Initial beta release

\section{Acknowledgements}

The \href{http://tex.stackexchange.com}{\TeX.SE community}
has been a constant source of help, inspiration, and amazement.

I'd also like to register my thanks to the owners of the packages and tools 
on which \tpname\ depends: 
biblatex, etoolbox, hyperref, and kvoptions,
and also to 
\href{http://tex.stackexchange.com/users/35864/moewe}{moewe at \TeX.SE} for
invaluable help during my ongoing stumblings with \sfit{biblatex}.

We all depend heavily on the constant hard work
so unstintingly given to the community by the Guardians of CTAN. 
Thank you all.

The failings, of course, I claim for myself.

% - - - - - - - - - - - - - - - - - - - - - - - - - - -
\section{Copyright \& licence}
Copyright \copyright\ \DTMfetchyear{gitdate}, Brent Longborough,
who has asserted his moral right
to be identified as the author of this work.

This work --- \tpname\ --- may be distributed and/or modified under the
conditions of the LaTeX Project Public License: either version 1.3
of this license, or (at your option) any later version.

The latest version of this license can be found
at the \LaTeX\ Project website,%
\footnote{(\url{http://www.latex-project.org/lppl.txt})}
and version 1.3 or later is part of all recent distributions of
\LaTeX.

This work has the LPPL maintenance status `maintained';
the Current Maintainer of this work is Brent Longborough.

% This work consists of the files
%     gitlog.sty, gitlog.bbx, gitlog.dbx, 
%     gitlog.tex, gitlog.sample.bib, gitHeadLocal.gin, 
%     gitlog.pdf, and README.md

% - - - - - - - - - - - - - - - - - - - - - - - - - - -
\section{From the author}
Although my limitations as a \TeX nician
mean that I'm going to need a lot of expert help
to turn \tpname\ into a delightful author experience,
I hope you find the package useful and the concept interesting.
I'll be very happy to receive your comments by email.\\[\baselineskip]
Brent Longborough\\[\baselineskip]
\textsf{brent+ctancontrib (bei) longborough (punkt) org}\\
and at \href{http://tex.stackexchange.com/users/344/brent-longborough}{\TeX.SE}
% -----------------------------------------------------
\printGitLog
% -----------------------------------------------------
\end{document}