From c44634d83c7976c229534edaf9ca6148b11822eb Mon Sep 17 00:00:00 2001
From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com>
Date: Thu, 16 Apr 2026 23:39:47 -0400
Subject: [PATCH] fix(release_setup): correctly count contributions for new
contributors
---
actions/release_setup/main.py | 12 +++++++++---
.../data/expected_release_notes_sample_0.md | 2 +-
.../data/expected_release_notes_sample_1.md | 2 +-
.../data/expected_release_notes_sample_2.md | 2 +-
4 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/actions/release_setup/main.py b/actions/release_setup/main.py
index 4b74114d..9c5ab137 100644
--- a/actions/release_setup/main.py
+++ b/actions/release_setup/main.py
@@ -286,9 +286,12 @@ def process_release_body(release_body: str) -> str:
"""
processed_body = ''
contributors = {}
+ in_new_contributors = False
for line in io.StringIO(release_body).readlines():
- processed_line = _process_line_for_contributors(line, contributors)
+ if line.strip() == '## New Contributors':
+ in_new_contributors = True
+ processed_line = _process_line_for_contributors(line, contributors, track=not in_new_contributors)
processed_body += processed_line
# add contributors to the release notes
@@ -299,7 +302,7 @@ def process_release_body(release_body: str) -> str:
return processed_body
-def _process_line_for_contributors(line: str, contributors: dict) -> str:
+def _process_line_for_contributors(line: str, contributors: dict, track: bool = True) -> str:
"""
Process a single line to replace mentions and track contributors.
@@ -309,6 +312,8 @@ def _process_line_for_contributors(line: str, contributors: dict) -> str:
The line to process.
contributors : dict
Dictionary to track contributor information.
+ track : bool
+ Whether to count this line toward the contributor's contribution count.
Returns
-------
@@ -324,7 +329,8 @@ def _process_line_for_contributors(line: str, contributors: dict) -> str:
return line
username = username_search.group(1)
- _track_contributor(username, contributors)
+ if track:
+ _track_contributor(username, contributors)
return _replace_mentions_and_pr_urls(line, username)
diff --git a/tests/release_setup/data/expected_release_notes_sample_0.md b/tests/release_setup/data/expected_release_notes_sample_0.md
index 2aaa7526..f0f9b53d 100644
--- a/tests/release_setup/data/expected_release_notes_sample_0.md
+++ b/tests/release_setup/data/expected_release_notes_sample_0.md
@@ -152,4 +152,4 @@
---
## Contributors
-


















+


















diff --git a/tests/release_setup/data/expected_release_notes_sample_1.md b/tests/release_setup/data/expected_release_notes_sample_1.md
index c13f5cfc..9aa5b8f7 100644
--- a/tests/release_setup/data/expected_release_notes_sample_1.md
+++ b/tests/release_setup/data/expected_release_notes_sample_1.md
@@ -8,4 +8,4 @@
---
## Contributors
-
+
diff --git a/tests/release_setup/data/expected_release_notes_sample_2.md b/tests/release_setup/data/expected_release_notes_sample_2.md
index 20a7e769..a84cb942 100644
--- a/tests/release_setup/data/expected_release_notes_sample_2.md
+++ b/tests/release_setup/data/expected_release_notes_sample_2.md
@@ -10,4 +10,4 @@
---
## Contributors
-![renovate[bot]: 2 merges renovate[bot]](https://avatars.githubusercontent.com/in/2740?size=40)
+