package solutions.tretter.githugandroid

/**
 * Port of the upstream ruby-githug `squash` 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 squashLevel(): Level = level(
    id = "squash",
    title = "Squash",
    description = "You have committed several times but would like all those changes to be one commit.",
    hints = listOf("Take a look at the `-i` flag of the rebase command."),
    commandSuggestions = listOf("git rebase -i HEAD~4"),
    setup = { RepoState(initialized = true, commits = listOf(CommitNode("1", "Initial Commit"), CommitNode("2", "Adding README"), CommitNode("3", "Updating README (squash this commit into Adding README)"), CommitNode("4", "Updating README (squash this commit into Adding README)"), CommitNode("5", "Updating README (squash this commit into Adding README)")), branches = mapOf("master" to 5)) },
    validator = repoPredicate { repo -> repo.commits.size <= 2 && repo.commits.any { it.message == "Adding README" } },
    testCases = listOf(
        levelTestCase("interactive squash", "git rebase -i HEAD~4"),
    ),
)
