asciidoctor / asciidoctor.org

:globe_with_meridians: Asciidoctor project site. Composed in AsciiDoc. Baked with Awestruct.
https://asciidoctor.org
Other
322 stars 807 forks source link

New environment variable: git commit hash [enhancement] #930

Closed bhougland18 closed 3 years ago

bhougland18 commented 4 years ago

I would like a new environmental variable created that get the project's current Git commit hash. This would provide the author with the exact version of a document, which would be beneficial once it is printed to a pdf or to paper. This could work in conjunction with the Asciidoctor barcode extension so this information to be easily scannable.

To get the full SHA:

$ git rev-parse HEAD
cbf1b9a1be984a9f61b79a05f23b19f66d533537

To get the shortened version:

$ git rev-parse --short HEAD
cbf1b9a
holgerbrandl commented 3 years ago

What also would fix the problem, would be an option for the user to expose custom environment variables to the document. So essentially a more extensive variable support.

mojavelinux commented 3 years ago

This is not the right repository to report issues for the software. This is the website repository.

Even then, Asciidoctor doesn't know anything about git. You could make a preprocessor extension that adds the attribute to the document by reading from the local environment. In fact, you will find a similar extension in the lab. https://github.com/asciidoctor/asciidoctor-extensions-lab/pull/95

All also mention that if you use Antora, then information about the git reference is injected into the document via attributes. See https://gitlab.com/antora/antora/-/issues/578