Choose tasks at random

This commit is contained in:
Nassim Jahnke 2024-12-13 17:04:25 +01:00
parent 8324be321a
commit 344088ae5b
No known key found for this signature in database
GPG key ID: EF6771C01F6EF02F

View file

@ -8,6 +8,7 @@ import java.nio.file.Files
import java.nio.file.SimpleFileVisitor import java.nio.file.SimpleFileVisitor
import kotlin.io.path.* import kotlin.io.path.*
import java.nio.file.Path import java.nio.file.Path
import kotlin.random.Random
plugins { plugins {
id("io.papermc.paperweight.core") version "2.0.0-SNAPSHOT" apply false id("io.papermc.paperweight.core") version "2.0.0-SNAPSHOT" apply false
@ -98,7 +99,13 @@ tasks.register("gibWork") {
val end = html.indexOf("```", start + beginMarker.length) val end = html.indexOf("```", start + beginMarker.length)
val taskList = html.substring(start + beginMarker.length, end) val taskList = html.substring(start + beginMarker.length, end)
val next = taskList.split("\\n").first { it.startsWith("- [ ]") }.replace("- [ ] ", "") // Extract all incomplete tasks and select a random one
val incompleteTasks = taskList.split("\\n").filter { it.startsWith("- [ ]") }.map { it.replace("- [ ] ", "") }
if (incompleteTasks.isEmpty()) {
error("No incomplete tasks found in the task list.")
}
val next = incompleteTasks[Random.nextInt(incompleteTasks.size)]
println("checking out $next...") println("checking out $next...")
val dir = patchesFolder.resolve("unapplied").resolve(next) val dir = patchesFolder.resolve("unapplied").resolve(next)