Skip to content

Get Template Version in Templates? #2161

Answered by rondefreitas
rondefreitas asked this question in Q&A
Discussion options

You must be logged in to vote

Digging through the source, turns out there's an undocumented property _commit that's available in the questions template and can easily be made the default for an answer variable like so, while handling for dirty commits:

source_commit:
    type: str
    when: false
    default: "{% if '-' in _commit %}{{ _copier_conf.vcs_ref_hash }}{% else %}{{ _commit }}{% endif %}"

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@pawamoy
Comment options

pawamoy May 22, 2025
Collaborator

@sisp
Comment options

sisp May 22, 2025
Maintainer

@rondefreitas
Comment options

Answer selected by rondefreitas
@rondefreitas
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants