summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/gitlog
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2015-11-23 23:06:21 +0000
committerKarl Berry <karl@freefriends.org>2015-11-23 23:06:21 +0000
commit10e6d3f05da678388e44f25765c633b29fe6e170 (patch)
treef19b08d06029b91dee7ff7393861a0dc4561c098 /Master/texmf-dist/tex/latex/gitlog
parent47e31c7a10c1ad9aabcbd1aefaa35c029eae6a3b (diff)
gitlog (22nov15)
git-svn-id: svn://tug.org/texlive/trunk@38932 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/gitlog')
-rw-r--r--Master/texmf-dist/tex/latex/gitlog/gitlog.bbx45
-rw-r--r--Master/texmf-dist/tex/latex/gitlog/gitlog.dbx17
-rw-r--r--Master/texmf-dist/tex/latex/gitlog/gitlog.sty111
3 files changed, 173 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/gitlog/gitlog.bbx b/Master/texmf-dist/tex/latex/gitlog/gitlog.bbx
new file mode 100644
index 00000000000..87e24ec2814
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/gitlog/gitlog.bbx
@@ -0,0 +1,45 @@
+\ProvidesFile{gitlog.bbx}[2015/11/22 0.0.beta]
+
+\defbibenvironment{bibliography}
+ {\list
+ {\printfield{entrykey}}%
+ {\setlength{\leftmargin}{5em}%
+ \setlength{\labelwidth}{0em}%
+ \setlength{\itemindent}{-\leftmargin}%
+ % \setlength{\itemindent}{0pt}%
+ \setlength{\itemsep}{\bibitemsep}%
+ % \addtolength{\leftmargin}{\labelsep}%
+ \setlength{\parsep}{\bibparsep}%
+ \renewcommand*{\makelabel}[1]{%
+ \makebox[5em]{\ttfamily##1}}}}
+ {\endlist}
+ {\item}
+
+\newbibmacro*{begentry}{}
+\newbibmacro*{finentry}{\finentry}
+
+\DeclareBibliographyDriver{gitcommit}{%
+ \usebibmacro{bibindex}%
+ \usebibmacro{begentry}%
+ \usebibmacro{title}%
+ \newblock%
+ \usebibmacro{date+author}%
+ \usebibmacro{finentry}}
+
+\newbibmacro*{commithash}{%
+ \printfield{commithash}%
+}
+
+% \newbibmacro*{entrykey}{%
+ % \href{https://github.com/Hightor/gitlog/commit/\thefield{commithash}}{\printfield{entrykey}}%
+% }
+
+% \DeclareFieldFormat{entrykey}{%
+ % \IfStrEq{}{\gitLog@github}{%
+ % #1
+ % }{%
+ % \href{https://github.com/\gitLog@github/commit/\thefield{commithash}}{#1}
+ % }
+% }
+
+\endinput
diff --git a/Master/texmf-dist/tex/latex/gitlog/gitlog.dbx b/Master/texmf-dist/tex/latex/gitlog/gitlog.dbx
new file mode 100644
index 00000000000..47d381d4ccd
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/gitlog/gitlog.dbx
@@ -0,0 +1,17 @@
+\ProvidesFile{gitlog.dbx}[2015/11/22 0.0.beta]
+
+\DeclareDatamodelEntrytypes{gitcommit}
+\DeclareDatamodelFields[type=field,datatype=verbatim]{
+ title,
+}
+\DeclareDatamodelFields[type=field,datatype=literal]{
+ commithash,
+}
+\DeclareDatamodelEntryfields[gitcommit]{
+ title,
+ author,
+ date,
+ commithash,
+}
+
+\endinput
diff --git a/Master/texmf-dist/tex/latex/gitlog/gitlog.sty b/Master/texmf-dist/tex/latex/gitlog/gitlog.sty
new file mode 100644
index 00000000000..6c6a527a8d7
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/gitlog/gitlog.sty
@@ -0,0 +1,111 @@
+% gitlog.sty
+% 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.
+% -----------------------------------------------------
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{gitlog}[2015/11/22 0.0.beta typeset git change log]
+\RequirePackage{etoolbox}
+\RequirePackage{kvoptions}
+\RequirePackage[%
+ datamodel=gitlog,
+ bibstyle=gitlog,
+ sorting=none,
+ date=iso8601,
+ firstinits=true,
+ defernumbers=true,
+ backend=biber,
+]{biblatex}
+
+\SetupKeyvalOptions{family=gitlog,prefix=gitLog@}
+\DeclareBoolOption[false]{date}
+\DeclareComplementaryOption{nodate}{date}
+\DeclareStringOption[Change Log]{title}
+% write:
+\DeclareBoolOption[true]{write}
+\AddToKeyvalOption{gitlog}{write}{\def\gitLog@writeset{true}}
+% nowrite:
+\DeclareComplementaryOption{nowrite}{write}
+\AddToKeyvalOption{gitlog}{nowrite}{\def\gitLog@writeset{true}}
+% bibfile:
+\DeclareStringOption{bibfile}
+% set up github option depending on hyperref
+\@ifpackageloaded{hyperref}{%
+ \DeclareStringOption[]{github}
+ \DeclareStringOption[]{bitbucket}
+}{%
+ \DeclareVoidOption{github}{%
+ \PackageError{gitlog}{I can't generate GitHub links unless you load hyperref.}
+ }
+ \DeclareVoidOption{bitbucket}{%
+ \PackageError{gitlog}{I can't generate Bitbucket links unless you load hyperref.}
+ }
+}
+% process options:
+\ProcessKeyvalOptions{gitlog}
+% check if write/nowrite has been set:
+\ifdef\gitLog@writeset
+ {}
+ {% write/nowrite option has not been set,
+ % set boolean depending on value of \gitLog@bibfile:
+ \ifdefempty\gitLog@bibfile
+ {\booltrue{gitLog@write}}
+ {\boolfalse{gitLog@write}}%
+ }
+% set default for bibfile if necessary
+\ifdefempty\gitLog@bibfile
+ {\def\gitLog@bibfile{\jobname.gitlog.bib}}{}
+% make entrykey a link if github link requested
+\DeclareFieldFormat{entrykey}{\ttfamily[#1]}
+\@ifpackageloaded{hyperref}{%
+ \ifdefempty\gitLog@github{}{%
+ \DeclareFieldFormat{entrykey}{%
+ \href{https://github.com/\gitLog@github/commit/\thefield{commithash}}{\ttfamily[#1]}%
+ }
+ }
+ \ifdefempty\gitLog@bitbucket{}{%
+ \DeclareFieldFormat{entrykey}{%
+ \href{https://bitbucket.org/\gitLog@bitbucket/commits/\thefield{commithash}}{\ttfamily[#1]}%
+ }
+ }
+}{}
+\newcommand{\printGitLog}{%
+ \nocite{*}
+ \raggedright
+ \printbibliography[title={\gitLog@title},type=gitcommit]
+}
+\ifgitLog@date
+ \newbibmacro*{date+author}{%
+ \printtext{\\}%
+ \usebibmacro{date}%
+ \setunit*{, }%
+ \usebibmacro{author}%
+ }
+\else
+ \newbibmacro*{date+author}{%
+ \relax
+ }
+\fi
+\ifgitLog@write
+ {\catcode`\%=12
+ \immediate\write18{
+ git --no-pager log --reverse --pretty="format:@gitcommit{%h,%n
+ author = {%an},%n
+ date = {%ad},%n
+ title = {%B},%n
+ commithash = {%H}
+ }" --date=short > \gitLog@bibfile}
+ }
+\else
+ \relax
+\fi
+\addbibresource{\gitLog@bibfile}