package solutions.tretter.githugandroid

/**
 * Port of the upstream ruby-githug `pull` 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 pullLevel(): Level = level(
    id = "pull",
    title = "Pull",
    description = "You need to pull changes from your origin repository.",
    hints = listOf("Check out the remote repositories and research `git pull`."),
    commandSuggestions = listOf("git pull origin master"),
    setup = { RepoState(initialized = true, remotes = mapOf("origin" to "remote"), branches = mapOf("master" to 1)) },
    validator = repoPredicate { repo ->
        "origin/master" in repo.fetchedBranches &&
            repo.files.any { it.name == "remote_file" && it.tracked } &&
            repo.commits.size >= 2
    },
    testCases = listOf(
        levelTestCase("pull explicit remote branch", "git pull origin master"),
        levelTestCase("pull default origin", "git pull"),
    ),
)
