Skip to content

Commit

Permalink
ci: processing changelog [no ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
Yakutoc committed Dec 3, 2024
1 parent 7a6ab78 commit b38658c
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions .github/actions/processing-release-changelog/groupByHeadings.js
Original file line number Diff line number Diff line change
@@ -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];
Expand All @@ -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 {
Expand All @@ -36,7 +36,6 @@ export function groupByHeadings(tree) {
}
}

// Сохраняем последнюю группу
if (currentGroup && currentNodes.length) {
if (!groups.has(currentGroup)) {
groups.set(currentGroup, []);
Expand All @@ -45,7 +44,6 @@ export function groupByHeadings(tree) {
groups.get(currentGroup).push(...currentNodes);
}

// Создаем новое дерево
const newChildren = [];

for (const [_, nodes] of groups) {
Expand Down

0 comments on commit b38658c

Please sign in to comment.