Skip to content

Commit

Permalink
Fix auto-closing with unfinished tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
krystof-k committed Mar 10, 2024
1 parent 75f64cb commit dfc4647
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
Expand Down

0 comments on commit dfc4647

Please sign in to comment.