Skip to content

Commit d4f786c

Browse files
committed
fix: avoid duplicates in versions and changelogs
1 parent 37d815a commit d4f786c

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

.github/scripts/update_versions_and_changelogs.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,8 +470,19 @@ def save_changelogs_for_injection(changelog_entries):
470470
if normalized_path not in existing_changelogs:
471471
existing_changelogs[normalized_path] = []
472472

473-
# Prepend new entry (most recent first)
474-
existing_changelogs[normalized_path].insert(0, new_entry)
473+
# Check if this version already exists (avoid duplicates)
474+
existing_versions = [entry.get('version') for entry in existing_changelogs[normalized_path]]
475+
if new_entry['version'] in existing_versions:
476+
# Update existing entry instead of adding duplicate
477+
for i, entry in enumerate(existing_changelogs[normalized_path]):
478+
if entry.get('version') == new_entry['version']:
479+
# Update date and summary
480+
existing_changelogs[normalized_path][i] = new_entry
481+
print(f"[INFO] Updated existing changelog entry for {normalized_path} v{new_entry['version']}")
482+
break
483+
else:
484+
# Prepend new entry (most recent first)
485+
existing_changelogs[normalized_path].insert(0, new_entry)
475486

476487
# Keep only last 20 entries per file (limit history size)
477488
existing_changelogs[normalized_path] = existing_changelogs[normalized_path][:20]

0 commit comments

Comments
 (0)