| 64 | const seeded: SeededSubscriptions = { stale: [], active: [] }; |
| 65 | const pulls: Array<{ pr: PullRequest; stale: boolean; sets: EventType[][] }> = []; |
| 66 | const open = async (stale: boolean) => { |
| 67 | const branch = `${stale ? "abandoned" : "parallel"}-change-${pulls.length + 1}`; |
| 68 | await git(workDir, env, "switch", "-c", branch, "main"); |
| 69 | await writeFile(join(workDir, `${branch}.txt`), `${branch}\n`); |
| 70 | await git(workDir, env, "add", `${branch}.txt`); |
| 71 | await git(workDir, env, "commit", "-m", `Add ${branch}`); |
| 72 | await git(workDir, env, "push", "--set-upstream", "origin", branch); |
| 73 | await git(workDir, env, "switch", "main"); |
| 74 | const pr = await github.api<PullRequest>("POST", `/repos/${repo}/pulls`, { |
| 75 | title: stale ? `Abandoned change ${pulls.length + 1}` : `Parallel change ${pulls.length + 1}`, |
| 76 | head: branch, base: "main", body: "Another change in this repository.", |
| 77 | }); |
| 78 | pulls.push({ pr, stale, sets: [...eventTypeSets] }); |
| 79 | }; |
| 80 | for (let count = 0; ; count++) { |
| 81 | if (count >= maxSeeded) throw new Error(`The subscription limit was not reached after ${maxSeeded} subscriptions`); |
| 82 | let next = pulls.filter(pull => pull.sets.length).sort((a, b) => b.sets.length - a.sets.length)[0]; |