Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
dokumente
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sven
dokumente
Commits
cdab623a
Commit
cdab623a
authored
7 years ago
by
rohieb
Browse files
Options
Downloads
Patches
Plain Diff
add vc bundle to include Git commit info in TeX documents
parent
889dcee2
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
.gitignore
+2
-0
2 additions, 0 deletions
.gitignore
.latexmkrc
+6
-0
6 additions, 0 deletions
.latexmkrc
Makefile
+6
-2
6 additions, 2 deletions
Makefile
scripts/vc
+41
-0
41 additions, 0 deletions
scripts/vc
scripts/vc-git.awk
+83
-0
83 additions, 0 deletions
scripts/vc-git.awk
with
138 additions
and
2 deletions
.gitignore
+
2
−
0
View file @
cdab623a
...
...
@@ -8,3 +8,5 @@
*.out
*.fdb_latexmk
*.ps
scripts/vc.tex
vc.tex
This diff is collapsed.
Click to expand it.
.latexmkrc
0 → 100644
+
6
−
0
View file @
cdab623a
$latex = 'make vc.tex; latex %O %S';
$pdflatex = 'make vc.tex; pdflatex %O %S';
$xetex = 'make vc.tex; xetex %O %S';
$xelatex = 'make vc.tex; xelatex %O %S';
$luatex = 'make vc.tex; luatex %O %S';
$lualatex = 'make vc.tex; lualatex %O %S';
This diff is collapsed.
Click to expand it.
Makefile
+
6
−
2
View file @
cdab623a
...
...
@@ -35,7 +35,8 @@ clean:
$(
addsuffix .fls,
$(
JOBNAMES
))
\
$(
addsuffix .log,
$(
JOBNAMES
))
\
$(
addsuffix .out,
$(
JOBNAMES
))
\
$(
addsuffix .toc,
$(
JOBNAMES
))
$(
addsuffix .toc,
$(
JOBNAMES
))
\
vc.tex
mrproper
:
clean
rm
-f
$(
PDFS
)
...
...
@@ -43,7 +44,10 @@ mrproper: clean
preview
:
$(
latexmk
)
-pvc
$(
LATESTJOB
)
.tex
%.pdf
:
%.tex
vc.tex
:
.git/index .git/HEAD scripts/vc scripts/vc-git.awk
cd
scripts
;
sh ./vc
-m
&&
mv
vc.tex ..
%.pdf
:
%.tex vc.tex
$(
latexmk
)
$(
if
$(
PVC
)
,-pvc,-pvc-
)
"
$<
"
# vim: ft=make ts=8 noet
This diff is collapsed.
Click to expand it.
scripts/vc
0 → 100755
+
41
−
0
View file @
cdab623a
#!/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
# Query all info from git log
logformat
=
""
logformat
=
"
${
logformat
}
Hash: %H%n"
logformat
=
"
${
logformat
}
AbrHash: %h%n"
logformat
=
"
${
logformat
}
ParentHashes: %P%n"
logformat
=
"
${
logformat
}
AbrParentHashes: %p%n"
logformat
=
"
${
logformat
}
AuthorName: %an%n"
logformat
=
"
${
logformat
}
AuthorEmail: %ae%n"
logformat
=
"
${
logformat
}
AuthorDate: %ai%n"
logformat
=
"
${
logformat
}
CommitterName: %cn%n"
logformat
=
"
${
logformat
}
CommitterEmail: %ce%n"
logformat
=
"
${
logformat
}
CommitterDate: %ci%n"
LC_ALL
=
C
git
--no-pager
log
-1
HEAD
--pretty
=
format:
"
$logformat
"
\
| gawk
-v
script
=
log
-v
full
=
$full
-f
vc-git.awk
\
>
vc.tex
# Query modification status of the working copy
if
[
"
$mod
"
=
1
]
;
then
git status
--porcelain
=
v1
\
| gawk
-v
script
=
status
-f
vc-git.awk
\
>>
vc.tex
fi
This diff is collapsed.
Click to expand it.
scripts/vc-git.awk
0 → 100644
+
83
−
0
View file @
cdab623a
# 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
{
modified
=
0
}
### Process output of "git log".
script
==
"log"
&&
/^Hash:/
{
Hash
=
substr
(
$0
,
2
+
match
(
$0
,
":"
))
}
script
==
"log"
&&
/^AbrHash:/
{
AbrHash
=
substr
(
$0
,
2
+
match
(
$0
,
":"
))
}
script
==
"log"
&&
/^ParentHashes:/
{
ParentHashes
=
substr
(
$0
,
2
+
match
(
$0
,
":"
))
}
script
==
"log"
&&
/^AbrParentHashes:/
{
AbrParentHashes
=
substr
(
$0
,
2
+
match
(
$0
,
":"
))
}
script
==
"log"
&&
/^AuthorName:/
{
AuthorName
=
substr
(
$0
,
2
+
match
(
$0
,
":"
))
}
script
==
"log"
&&
/^AuthorEmail:/
{
AuthorEmail
=
substr
(
$0
,
2
+
match
(
$0
,
":"
))
}
script
==
"log"
&&
/^AuthorDate:/
{
AuthorDate
=
substr
(
$0
,
2
+
match
(
$0
,
":"
))
}
script
==
"log"
&&
/^CommitterName:/
{
CommitterName
=
substr
(
$0
,
2
+
match
(
$0
,
":"
))
}
script
==
"log"
&&
/^CommitterEmail:/
{
CommitterEmail
=
substr
(
$0
,
2
+
match
(
$0
,
":"
))
}
script
==
"log"
&&
/^CommitterDate:/
{
CommitterDate
=
substr
(
$0
,
2
+
match
(
$0
,
":"
))
}
### Process output of "git status".
### Changed index?
script
==
"status"
&&
/^
[
mMADRCU
]
/
{
modified
=
1
}
### Unstaged modifications?
script
==
"status"
&&
/^
[
mMADRCU
]
/
{
modified
=
1
}
### Unresolved merge conflicts?
script
==
"status"
&&
/^
[
mMADRCU
][
mMADRCU
]
/
{
modified
=
1
}
END
{
### Process output of "git log".
if
(
script
==
"log"
)
{
### Format dates
LongDate
=
substr
(
AuthorDate
,
1
,
25
)
DateRAW
=
substr
(
LongDate
,
1
,
10
)
DateISO
=
DateRAW
DateTEX
=
DateISO
gsub
(
"-"
,
"/"
,
DateTEX
)
Time
=
substr
(
LongDate
,
12
,
14
)
print
"%%% This file has been generated by the vc bundle for TeX."
print
"%%% Do not edit this file!"
print
"%%%"
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
"}%"
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
"%%% 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\\VCModifiedText{}%"
print
"\\gdef\\VCRevisionMod{\\VCRevision}%"
}
else
{
print
"\\gdef\\VCModifiedText{\\textcolor{red}{mit lokalen Änderungen}}%"
print
"\\gdef\\VCRevisionMod{\\VCRevision~\\VCModifiedText}%"
}
# footnote without a number:
print
"\\gdef\\VCfootnote{\\begingroup\\def\\thefootnote{}\\footnote{%"
print
"Erstellt aus \\url{https://github.com/stratum0/dokumente/blob/\\GITAbrHash/\\jobname.tex} \\VCModifiedText%"
print
"}\\addtocounter{footnote}{-1}\\endgroup}%"
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment