From b38658c40a16827015b9f19a21143e1824fcc787 Mon Sep 17 00:00:00 2001 From: Alexander Lobyntsev Date: Tue, 3 Dec 2024 12:32:00 +0700 Subject: [PATCH] ci: processing changelog [no ci] --- .../groupByHeadings.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/actions/processing-release-changelog/groupByHeadings.js b/.github/actions/processing-release-changelog/groupByHeadings.js index db1545798c..ecbc9b0e4d 100644 --- a/.github/actions/processing-release-changelog/groupByHeadings.js +++ b/.github/actions/processing-release-changelog/groupByHeadings.js @@ -1,10 +1,10 @@ export function groupByHeadings(tree) { const groups = new Map(); - let nodes = [...tree.children]; + const h2List = new Set(); + let nodes = [...tree.children]; let currentGroup = null; let currentNodes = []; - let isFirstMainHeading = new Set(); // Для отслеживания первого вхождения заголовка for (let i = 0; i < nodes.length; i++) { const node = nodes[i]; @@ -21,12 +21,12 @@ export function groupByHeadings(tree) { } currentGroup = headingValue; - // Добавляем заголовок в группу только если он встречается первый раз - if (!isFirstMainHeading.has(headingValue)) { + + if (!h2List.has(headingValue)) { currentNodes = [node]; - isFirstMainHeading.add(headingValue); + + h2List.add(headingValue); } else { - // Пропускаем повторный заголовок currentNodes = []; } } else { @@ -36,7 +36,6 @@ export function groupByHeadings(tree) { } } - // Сохраняем последнюю группу if (currentGroup && currentNodes.length) { if (!groups.has(currentGroup)) { groups.set(currentGroup, []); @@ -45,7 +44,6 @@ export function groupByHeadings(tree) { groups.get(currentGroup).push(...currentNodes); } - // Создаем новое дерево const newChildren = []; for (const [_, nodes] of groups) {