How to trim empty lines from commit message? #5091
Closed
thomaseizinger
started this conversation in
General
Replies: 1 comment 7 replies
-
Hi, {{ title }}
{{ body | get_section("## Description", "") }}
Pull-Request: #{{ number }}.
{# Here comes some fancy Jinja2 stuff for correctly attributing co-authorship: #}
{%- for commit in (commits | unique(False, 'email_author')) | rejectattr("author", "==", author) -%}
{%- if commit.parents|length == 1 -%}
Co-Authored-By: {{ commit.author }} <{{ commit.email_author }}>
{%- endif -%}
{%- endfor -%}
{# GitHub requires that the `Co-authored-by` lines are AT THE VERY END of a commit, hence nothing must come after this. #} Hope it's what you are looking for 😉 |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
We have the following commit message template:
Here is an example commit that got generated: libp2p/rust-libp2p@b8ceecc
As you can see, there are multiple empty lines. Ideally, I would like to control these empty lines somehow. My expectation was that - because I did not add any empty lines between
Pull-Request
and the comment - there would be no empty lines. Yet it seems that the template engine adds additional empty lines?Can this be avoided somehow?
Also, not all our PRs have a
## Description
section (or it is empty). Ideally I'd like to somehow avoid additional empty lines in that case.If we go after https://cbea.ms/git-commit/, then a commit message should never have more than a single empty line as a separator. That is what I want to achieve. Would it be possible to automatically trim additional empty lines from inside the template?
Beta Was this translation helpful? Give feedback.
All reactions