package solutions.tretter.githugandroid

/**
 * Port of the upstream ruby-githug `commit` 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 commitLevel(): Level = level(
    id = "commit",
    title = "Commit",
    description = "The `README` file has been added to your staging area, now commit it.",
    hints = listOf("You must include a message when you commit."),
    commandSuggestions = listOf("git commit -m \"Initial commit\"", "git log"),
    setup = { RepoState(initialized = true, files = listOf(GitFile("README", staged = true)), branches = mapOf("master" to 0)) },
    validator = repoPredicate { it.commits.isNotEmpty() && it.files.any { file -> file.name == "README" && file.tracked && !file.staged } },
    testCases = listOf(
        levelTestCase("commit with message", "git commit -m \"Initial commit\""),
        levelTestCase("commit with alternate message", "git commit -m \"Add README\""),
    ),
)
