From 1f800bdc8be30e2d76b39a723a36bfabfa83813f Mon Sep 17 00:00:00 2001 From: Ari Seyhun Date: Thu, 10 Oct 2024 00:06:47 +0800 Subject: [PATCH] chore: add pr detection to git cliff contributors --- cliff.toml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/cliff.toml b/cliff.toml index 3021485..eb34f3e 100644 --- a/cliff.toml +++ b/cliff.toml @@ -23,10 +23,19 @@ body = """ ## [Unreleased] {% endif -%} {% for contributor in github.contributors | filter(attribute="is_first_time", value=true) %} - * @{{ contributor.username }} made their first contribution in #{{ contributor.pr_number }} -{%- endfor -%} -{%- if github.contributors | length > 0 %} -{% endif -%} + * @{{ contributor.username }} made their first contribution + {%- if contributor.pr_number %} in #{{ contributor.pr_number -}} + {%- else -%} + {#- find the commit -#} + {% for commit in commits -%} + {%- if commit.id == commit_id -%} + {%- set pr = commit.message | split(pat="#") | last | trim_end_matches(pat=")") -%} + {%- if pr is matching("^\\d+$") %} in #{{ pr }}{%- endif -%} + {%- break -%} + {%- endif -%} + {%- endfor -%} + {%- endif -%} +{%- endfor %} {% for group, commits in commits | group_by(attribute="group") %} ### {{ group | upper_first }} {% for commit in commits | sort(attribute="author.timestamp") | reverse | sort(attribute="breaking") | reverse %}