Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 90 lines (77 sloc) 3.372 kb
c8804ab @kjhealy vc-git.awk tracker
authored
1 # This is file 'vc-git.awk' from the vc bundle for TeX.
2 # The original file can be found at CTAN:support/vc.
3 # This file is Public Domain.
4 BEGIN {
5
6 ### Process output of "git status".
7 if (script=="status") {
8 modified = 0
9 }
10
11 }
12
13
14
15 ### Process output of "git log".
16 script=="log" && /^Hash:/ { Hash = substr($0, 2+match($0, ":")) }
17 script=="log" && /^Abr. Hash:/ { AbrHash = substr($0, 2+match($0, ":")) }
18 script=="log" && /^Parent Hashes:/ { ParentHashes = substr($0, 2+match($0, ":")) }
19 script=="log" && /^Abr. Parent Hashes:/ { AbrParentHashes = substr($0, 2+match($0, ":")) }
20 script=="log" && /^Author Name:/ { AuthorName = substr($0, 2+match($0, ":")) }
21 script=="log" && /^Author Email:/ { AuthorEmail = substr($0, 2+match($0, ":")) }
22 script=="log" && /^Author Date:/ { AuthorDate = substr($0, 2+match($0, ":")) }
23 script=="log" && /^Committer Name:/ { CommitterName = substr($0, 2+match($0, ":")) }
24 script=="log" && /^Committer Email:/ { CommitterEmail = substr($0, 2+match($0, ":")) }
25 script=="log" && /^Committer Date:/ { CommitterDate = substr($0, 2+match($0, ":")) }
26
27 ### Process output of "git status".
28 ### Changed index?
29 script=="status" && /^# Changes to be committed:/ { modified = 1 }
30 ### Unstaged modifications?
31 script=="status" && /^# Changed but not updated:/ { modified = 2 }
32
33
34
35 END {
36
37 ### Process output of "git log".
38 if (script=="log") {
39 ### Standard encoding is UTF-8.
40 if (Encoding == "") Encoding = "UTF-8"
41 ### Extract relevant information from variables.
42 LongDate = substr(AuthorDate, 1, 25)
43 DateRAW = substr(LongDate, 1, 10)
44 DateISO = DateRAW
45 DateTEX = DateISO
46 gsub("-", "/", DateTEX)
47 Time = substr(LongDate, 12, 14)
48 ### Write file identification to vc.tex.
49 print "%%% This file has been generated by the vc bundle for TeX."
50 print "%%% Do not edit this file!"
51 print "%%%"
52 ### Write Git specific macros.
53 print "%%% Define Git specific macros."
54 print "\\gdef\\GITHash{" Hash "}%"
55 print "\\gdef\\GITAbrHash{" AbrHash "}%"
56 print "\\gdef\\GITParentHashes{" ParentHashes "}%"
57 print "\\gdef\\GITAbrParentHashes{" AbrParentHashes "}%"
58 print "\\gdef\\GITAuthorName{" AuthorName "}%"
59 print "\\gdef\\GITAuthorEmail{" AuthorEmail "}%"
60 print "\\gdef\\GITAuthorDate{" AuthorDate "}%"
61 print "\\gdef\\GITCommitterName{" CommitterName "}%"
62 print "\\gdef\\GITCommitterEmail{" CommitterEmail "}%"
63 print "\\gdef\\GITCommitterDate{" CommitterDate "}%"
64 ### Write generic version control macros.
65 print "%%% Define generic version control macros."
66 print "\\gdef\\VCRevision{\\GITAbrHash}%"
67 print "\\gdef\\VCAuthor{\\GITAuthorName}%"
68 print "\\gdef\\VCDateRAW{" DateRAW "}%"
69 print "\\gdef\\VCDateISO{" DateISO "}%"
70 print "\\gdef\\VCDateTEX{" DateTEX "}%"
71 print "\\gdef\\VCTime{" Time "}%"
72 print "\\gdef\\VCModifiedText{\\textcolor{red}{with local modifications!}}%"
73 print "%%% Assume clean working copy."
74 print "\\gdef\\VCModified{0}%"
75 print "\\gdef\\VCRevisionMod{\\VCRevision}%"
76 }
77
78 ### Process output of "git status".
79 if (script=="status") {
80 print "%%% Is working copy modified?"
81 print "\\gdef\\VCModified{" modified "}%"
82 if (modified==0) {
83 print "\\gdef\\VCRevisionMod{\\VCRevision}%"
84 } else {
85 print "\\gdef\\VCRevisionMod{\\VCRevision~\\VCModifiedText}%"
86 }
87 }
88
89 }
Something went wrong with that request. Please try again.