Re: [NTG-context] typesetting information from git

2018-02-23 Thread Schmitz Thomas A.


> On 23. Feb 2018, at 22:00, Hans Hagen  wrote:
> 
> maybe you mean
> 
> \startluacode
> 
> context.setupdocument {
>gitversion = string.strip(
>os.resultof("git --no-pager log --pretty='%h of %aD' -1 " .. 
> environment.jobfilefullname) or "")
> }
> 
> \stopluacode
> 
> \setupfootertexts
> [this is from file: \documentvariable{gitversion}]
> 
> \starttext
> 
> [[\ctxlua{context(environment.jobfilefullname)}]]
> 
> [[\ctxlua{context(environment.jobfilename)}]]
> 
> \ctxlua{inspect(table.sortedkeys(environment))}
> 
> test
> 
> \stoptext

Yes, sorry, I wasn’t clear enough. environment.jobfilefullname is excellent, I 
can work from here. Just to provide a clearer explanation: I have an 
environment style.tex. With it, I process a number of xml files: foo.xml, 
bar.xml, arg.xml with the call

context —environment style foo.xml etc.

and I want the git revision of the xml file printed not of the style file, 
obviously). jobfilefullname does what I want, and I’ll look into the other 
variables as well. Very handy, thanks!

Thomas
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

Re: [NTG-context] typesetting information from git

2018-02-23 Thread Hans Hagen

On 2/23/2018 9:38 PM, Schmitz Thomas A. wrote:

Hi,

I like to add a sort of watermark with info about the git revision at the 
bottom of some files that I typeset. I’m using Lua, so I have:

context(os.resultof("git --no-pager log --pretty='%h of %aD' -1 foo.xml”))

which gives something like "git revision b085c92a of Wed, 14 Feb 2018 12:49:35 
+0100.” Suppose I want to make this more general. What would be the easiest way to 
either say “the xml file that is being processed” (something like arg[1]) or “the 
xml file whose name is in the Lua variable ‘foo?’”


maybe you mean

\startluacode

context.setupdocument {
gitversion = string.strip(
os.resultof("git --no-pager log --pretty='%h of %aD' -1 " .. 
environment.jobfilefullname) or "")

}

\stopluacode

\setupfootertexts
 [this is from file: \documentvariable{gitversion}]

\starttext

[[\ctxlua{context(environment.jobfilefullname)}]]

[[\ctxlua{context(environment.jobfilename)}]]

\ctxlua{inspect(table.sortedkeys(environment))}

test

\stoptext






-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

Re: [NTG-context] typesetting information from git

2018-02-23 Thread Hans Hagen

On 2/23/2018 9:38 PM, Schmitz Thomas A. wrote:

Hi,

I like to add a sort of watermark with info about the git revision at the 
bottom of some files that I typeset. I’m using Lua, so I have:

context(os.resultof("git --no-pager log --pretty='%h of %aD' -1 foo.xml”))

which gives something like "git revision b085c92a of Wed, 14 Feb 2018 12:49:35 
+0100.” Suppose I want to make this more general. What would be the easiest way to 
either say “the xml file that is being processed” (something like arg[1]) or “the 
xml file whose name is in the Lua variable ‘foo?’”

I'm not sure if i understand well but something

\startluacode

context.setupdocument {
gitversion = string.strip(os.resultof("git --no-pager log 
--pretty='%h of %aD' -1 foo.tex") or "")

}

\stopluacode

\setupfootertexts
 [this is from file: \documentvariable{gitversion}]

\starttext

test

\stoptext

(as long as uou make sure you call the got command only once and not 
again in each footer)


-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___

[NTG-context] typesetting information from git

2018-02-23 Thread Schmitz Thomas A.
Hi,

I like to add a sort of watermark with info about the git revision at the 
bottom of some files that I typeset. I’m using Lua, so I have:

context(os.resultof("git --no-pager log --pretty='%h of %aD' -1 foo.xml”))

which gives something like "git revision b085c92a of Wed, 14 Feb 2018 12:49:35 
+0100.” Suppose I want to make this more general. What would be the easiest way 
to either say “the xml file that is being processed” (something like arg[1]) or 
“the xml file whose name is in the Lua variable ‘foo?’”

Thanks!

Thomas

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___