Skip to content
Discussion options

You must be logged in to vote

How about using, e.g., jinja2-shell-extension and calling your status command in a when template?

_jinja_extensions:
  - jinja2_shell_extension.ShellExtension

_tasks:
  - command: "git init"
    when: "{{ 'git log -1 --pretty=oneline && echo \"false\" || echo \"true\"' | shell }}"

(Disclaimer: I haven't tested this template, but this or something similar should work.)

Or you could register your own tiny Jinja2 extension that directly translates a shell exit code to "true"/"false". See, e.g., https://github.com/pawamoy/copier-uv/blob/main/extensions.py + https://github.com/pawamoy/copier-uv/blob/main/copier.yml#L11-L14.

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@wgordon17
Comment options

@wgordon17
Comment options

@wgordon17
Comment options

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