package solutions.tretter.githugandroid

/**
 * Port of the upstream ruby-githug `reorder` 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 reorderLevel(): Level = level(
    id = "reorder",
    title = "Reorder",
    description = "You have committed several times but in the wrong order. Please reorder your commits.",
    hints = listOf("Take a look the `-i` flag of the rebase command."),
    commandSuggestions = listOf("git rebase -i HEAD~3"),
    setup = { RepoState(initialized = true, commits = listOf(CommitNode("1", "Initial Setup"), CommitNode("2", "First commit"), CommitNode("3", "Third commit"), CommitNode("4", "Second commit")), branches = mapOf("master" to 4)) },
    validator = repoPredicate { repo -> repo.commits.map { it.message }.filter { it.endsWith("commit") } == listOf("First commit", "Second commit", "Third commit") },
    testCases = listOf(
        levelTestCase("interactive reorder", "git rebase -i HEAD~3"),
    ),
)
