From 41076f6acd36d118acb7dbbcf35a6238ae69925e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Zwoli=C5=84ski?= Date: Tue, 27 Jun 2023 14:01:22 +0200 Subject: [PATCH] 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 --- .github/mergify.yml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/mergify.yml b/.github/mergify.yml index 59424a29..62c5481b 100644 --- a/.github/mergify.yml +++ b/.github/mergify.yml @@ -4,15 +4,19 @@ defaults: method: squash commit_message_template: | {{ 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 %} + {%- set _ = 0 -%} + {%- for commit in commits -%} + {%- if commit.parents|length != 1 -%} + {%- set _ = commit.update({'merge': true}) -%} + {%- endif -%} + {%- endfor -%} + {%- for commit in (commits | rejectattr("merge") | unique(False, 'email_author')) | rejectattr("author", "==", author) -%} + Co-authored-by: {{ commit.author }} <{{ commit.email_author }}> {% endfor %} {# GitHub requires that the `Co-authored-by` lines are AT THE VERY END of a commit, hence nothing must come after this. #}