package solutions.tretter.githugandroid

/**
 * Port of the upstream ruby-githug `config` 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 configLevel(): Level = level(
    id = "config",
    title = "Config",
    description = "Set up your git name and email; this is important so that your commits can be identified.",
    hints = listOf("Use `git config user.name ...` and `git config user.email ...`."),
    commandSuggestions = listOf("git config user.name GitHug", "git config user.email githug@example.com"),
    setup = { RepoState(initialized = true, branches = mapOf("master" to 0)) },
    validator = repoPredicate { repo -> repo.config["user.name"].orEmpty().isNotBlank() && repo.config["user.email"].orEmpty().isNotBlank() },
    testCases = listOf(
        levelTestCase("name then email", "git config user.name GitHug", "git config user.email githug@example.com"),
        levelTestCase("email then name", "git config user.email githug@example.com", "git config user.name GitHug"),
    ),
)
