vaab / gitchangelog

Creates a changelog from git log history.
Other
584 stars 139 forks source link

Accessing trailers in template #108

Open viktoradavid opened 5 years ago

viktoradavid commented 5 years ago

Hi, the doc says it is possible to use trailers. However, can custom trailers really be accessed from the templates? I didn't manage to make it work and it doesn't seem like this is supported. Should the doc be updated? Thanks!

vaab commented 5 years ago

Hi, thanks for your interest in Gitchangelog and your time to report this.

Indeed, the README doesn't cover access to custom trailers. I'll keep this thread open until this is fixed.

Meanwhile, you can use: https://github.com/vaab/gitchangelog/blob/master/src/gitchangelog/gitchangelog.py#L791-L823

As a quick documentation how to use them. Knowing that template data can access directly commit object through

https://github.com/vaab/gitchangelog/blob/master/src/gitchangelog/gitchangelog.py#L1600

As you see, commit is the commit object, along the author, subject and body keys provided in the data structure that templates receives (as documented properly in the README.rst for these last 3 keys).

I'm afraid that all that is not documented properly. I hope that this is helping you getting access to what you need.

viktoradavid commented 5 years ago

Hi, I really appreciate your help! I was checking the sources you linked during my first investigation. However, I missed one thing while working with sample mako template - you basically need to use commit['commit'] to acces trailers. In case someone gets here in the future - to get e.g. trailer Subscribers: xyz, you need to use commit['commit'].trailer_subscribers.

Unfortunately, this does not solve my issue, since trailers we're working with contain spaces in the key, e.g. Maniphest Tasks: xyz (not sure if that's allowed in the specs, but that's what Phabricator does). I could prepare a PR to also allow spaces, but I'm not sure they are allowed..

Thanks again for a very helpful post and project!

vaab commented 5 years ago

Thanks for your feedback on this particular use case. I'll keep this issue open to keep track of a feature allowing access to trailer keys more traditionally (simple dict).