From 3a221a06019c518f8684e3545796c85057d41653 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kry=C5=A1tof=20Korb?= Date: Sun, 10 Mar 2024 20:09:15 +0100 Subject: [PATCH] Fix auto-closing with unfinished tasks --- index.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index 6d514b1..e1a8d6e 100644 --- a/index.js +++ b/index.js @@ -38,17 +38,16 @@ async function updateEpic({ octokit, epic }) { epicBody = epicBody.replace(match[0], match[0].replace(/- \[[ |x]\]/, `- [${convertedIssueState}]`)); }); - const patternAll = /- \[[ |x]\] .*#.*/gm; - const patternAllDone = /- \[[x]\] .*#.*/gm; - const matchesAll = Array.from(epicBody.matchAll(patternAll)); - const matchesAllCount = matchesAll.length; - const matchesAllDone = Array.from(epicBody.matchAll(patternAllDone)); - const matchesAllDoneCount = matchesAllDone.length; + const allTasksPattern = /- \[[ |x]\] .*/gm; + const doneTasksPattern = /- \[[x]\] .*/gm; + const allTasks = Array.from(epicBody.matchAll(allTasksPattern)); + const doneTasks = Array.from(epicBody.matchAll(doneTasksPattern)); + const allTasksCount = allTasks.length; + const doneTasksCount = doneTasks.length; if (!!autoCloseEpic && matchCount - && matchesAllCount - && matchesAllDoneCount === matchesAllCount + && allTasksCount === doneTasksCount ) { epicState = 'closed'; }