diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /support/vc/git-windows |
Initial commit
Diffstat (limited to 'support/vc/git-windows')
-rw-r--r-- | support/vc/git-windows/vc-git.awk | 81 | ||||
-rw-r--r-- | support/vc/git-windows/vc.bat | 24 |
2 files changed, 105 insertions, 0 deletions
diff --git a/support/vc/git-windows/vc-git.awk b/support/vc/git-windows/vc-git.awk new file mode 100644 index 0000000000..ec85071263 --- /dev/null +++ b/support/vc/git-windows/vc-git.awk @@ -0,0 +1,81 @@ +# 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(CommitterDate, 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 "\\gdef\\VCModifiedText{\\textcolor{red}{with local modifications!}}%" + + 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\\VCRevisionMod{\\VCRevision}%" + } else { + print "\\gdef\\VCRevisionMod{\\VCRevision~\\VCModifiedText}%" + } + } + +} diff --git a/support/vc/git-windows/vc.bat b/support/vc/git-windows/vc.bat new file mode 100644 index 0000000000..ede0d40156 --- /dev/null +++ b/support/vc/git-windows/vc.bat @@ -0,0 +1,24 @@ +@echo off +REM This is file 'vc.bat' from the vc bundle for TeX. +REM The original file can be found at CTAN:support/vc. +REM This file is Public Domain. + +setlocal +REM Parse command line options. +set full=0 +set mod=0 +:loopParams +if "%1" NEQ "" ( + if "%1"=="-f" (set full=1) else if "%1"=="-m" (set mod=1) else ( + echo usage: vc [-f] [-m] + exit /b 1 + ) + shift + goto loopParams +) +REM English locale. +set LC_ALL=C +git --no-pager log -1 HEAD --pretty=format:"Hash: %H%nAbr. Hash: %h%nParent Hashes: %P%nAbr. Parent Hashes: %p%nAuthor Name: %an%nAuthor Email: %ae%nAuthor Date: %ai%nCommitter Name: %cn%nCommitter Email: %ce%nCommitter Date: %ci%n" |gawk -v script=log -v full=%full% -f vc-git.awk > vc.tex +if "%mod%"=="1" ( + git status --porcelain=v1 |gawk -v script=status -f vc-git.awk >> vc.tex +) |