wemake-services/jinja2-git

Add `{% gitcommit short=True %}` option

sobolevn opened this issue · 3 comments

Currently this library only allows users to get the full commit hash.

I would see some possible usages of the short commit hash as well.
So, I would like to propose the following syntax for it: {% gitcommit short=True %}.

What needs to be done?

  1. we need to find out how to pass parameters to the jinja2 tags
  2. we need to add a new parameter to the _commit_hash method
  3. we need to write tests for this feature
  4. we need to write docs for this feature as well https://github.com/sobolevn/jinja2-git#usage

This was originally a # TODO comment: https://github.com/sobolevn/jinja2-git/blob/23172f3a7f26b6f551f70a8c6aaa818a79918e4f/jinja2_git.py#L22

I'm stuck at point 0.5: "Learn how to execute GitExtension.parse() manually".

I tried to execute the code without pytest, but I did not succeed.

Will this help you?

from jinja2 import Environment

env = Environment(extensions=['jinja2_git.GitExtension'])
template = env.from_string('Commit is: {% gitcommit %}')

This is an example from readme.

I'm very ashamed. Thank you much.