Skip to content

Commit 41076f6

Browse files
fix(ci): improve attribution of co-authors
Fix the `Co-authored-by` inclusion in commit messages so that co-authorship is properly expressed. Additionally, filter merge commits before unique authors. Previously, we would not attribute an author if their first commit in a PR was a merge commit. Finally, we remove superfluous newlines between the `Co-authored-by` lines. Pull-Request: #4104. Co-authored-by: Thomas Eizinger <[email protected]>
1 parent 5c362fc commit 41076f6

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

.github/mergify.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@ defaults:
44
method: squash
55
commit_message_template: |
66
{{ title }}
7-
7+
88
{{ body | get_section("## Description", "") }}
9-
9+
1010
Pull-Request: #{{ number }}.
1111
{# Here comes some fancy Jinja2 stuff for correctly attributing co-authorship: #}
12-
{% for commit in (commits | unique(False, 'email_author')) | rejectattr("author", "==", author) %}
13-
{% if commit.parents|length == 1 %}
14-
Co-Authored-By: {{ commit.author }} <{{ commit.email_author }}>
15-
{% endif %}
12+
{%- set _ = 0 -%}
13+
{%- for commit in commits -%}
14+
{%- if commit.parents|length != 1 -%}
15+
{%- set _ = commit.update({'merge': true}) -%}
16+
{%- endif -%}
17+
{%- endfor -%}
18+
{%- for commit in (commits | rejectattr("merge") | unique(False, 'email_author')) | rejectattr("author", "==", author) -%}
19+
Co-authored-by: {{ commit.author }} <{{ commit.email_author }}>
1620
{% endfor %}
1721
{# GitHub requires that the `Co-authored-by` lines are AT THE VERY END of a commit, hence nothing must come after this. #}
1822

0 commit comments

Comments
 (0)