public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Include Git Hash in PDF
@ 2022-01-20 14:45 'Jan Ulrich Hasecke' via pandoc-discuss
       [not found] ` <98ea588d-45d4-1d50-5d30-c7d676728c23-cl+VPiYnx/1AfugRpC6u6w@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: 'Jan Ulrich Hasecke' via pandoc-discuss @ 2022-01-20 14:45 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

Hi all,

I am lost.

How can I insert the commit hash from git in the output file?

I tried to evaluate "git rev-parse HEAD" in a build script and hand over 
the result to the build process by setting a custom variable to the hash 
string via --variable hash=${git rev-parse HEAD}. In my template I have 
$hash$

I stored the hash in a file and tried to include it with -B, though this 
would not be a good solution if it worked at all.

I guess this is quite a common requirement but I failed to find the 
solution with Google & Co.

Any hints
juh


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Include Git Hash in PDF
       [not found] ` <98ea588d-45d4-1d50-5d30-c7d676728c23-cl+VPiYnx/1AfugRpC6u6w@public.gmane.org>
@ 2022-01-20 15:20   ` 'Saku Laesvuori' via pandoc-discuss
  0 siblings, 0 replies; 2+ messages in thread
From: 'Saku Laesvuori' via pandoc-discuss @ 2022-01-20 15:20 UTC (permalink / raw)
  To: 'Jan Ulrich Hasecke' via pandoc-discuss

[-- Attachment #1: Type: text/plain, Size: 755 bytes --]

> I tried to evaluate "git rev-parse HEAD" in a build script and hand over the
> result to the build process by setting a custom variable to the hash string
> via --variable hash=${git rev-parse HEAD}. In my template I have $hash$

The syntax for including command output in a shell command line is
$(cmd), not ${cmd}. ${cmd} expands to the value of the shell variable
cmd instead of executing cmd. Your command line should thus look like

$ pandoc ... --variable "hash=$(git rev-parse HEAD)"


> I stored the hash in a file and tried to include it with -B, though this
> would not be a good solution if it worked at all.

Do you have $include-before$ somewhere in your template, if not then
pandoc doesn't know where to include the contents of the file.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-01-20 15:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-20 14:45 Include Git Hash in PDF 'Jan Ulrich Hasecke' via pandoc-discuss
     [not found] ` <98ea588d-45d4-1d50-5d30-c7d676728c23-cl+VPiYnx/1AfugRpC6u6w@public.gmane.org>
2022-01-20 15:20   ` 'Saku Laesvuori' via pandoc-discuss

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).