package solutions.tretter.githugandroid

/**
 * Port of the upstream ruby-githug `restructure` level.
 *
 * Setup documents the repository shape the learner explores. Evaluation is kept
 * state-based whenever the exercise changes repository objects; answer-only
 * levels intentionally validate the answer entered at the prompt.
 */
internal fun restructureLevel(): Level = level(
    id = "restructure",
    title = "Restructure",
    description = "You added some files to your repository, but now realize that your project needs to be restructured. Make a new folder named `src` and use Git move all of the .html files into this folder.",
    hints = listOf("You'll have to use mkdir, and `git mv`."),
    commandSuggestions = listOf("mkdir src", "git mv *.html src"),
    setup = { RepoState(initialized = true, files = listOf(GitFile("about.html", tracked = true), GitFile("contact.html", tracked = true), GitFile("index.html", tracked = true)), commits = listOf(CommitNode("0000001", "adding web content.")), branches = mapOf("master" to 1)) },
    validator = repoPredicate { repo -> listOf("src/about.html", "src/contact.html", "src/index.html").all { target -> repo.files.any { it.name == target } } && repo.files.none { it.name.endsWith(".html") && !it.name.startsWith("src/") && !it.deleted } },
    testCases = listOf(
        levelTestCase("move one by one", "mkdir src", "git mv about.html src/about.html", "git mv contact.html src/contact.html", "git mv index.html src/index.html"),
        levelTestCase("move with wildcard", "mkdir src", "git mv *.html src"),
    ),
)
