package solutions.tretter.githugandroid

/**
 * Port of the upstream ruby-githug `checkout_tag` 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 checkoutTagLevel(): Level = level(
    id = "checkout_tag",
    title = "Checkout Tag",
    description = "You need to fix a bug in the version 1.2 of your app. Checkout the tag `v1.2`.",
    hints = listOf("There's no big difference between checking out a branch and checking out a tag."),
    commandSuggestions = listOf("git checkout v1.2"),
    setup = { RepoState(initialized = true, commits = listOf(CommitNode("1", "Initial commit"), CommitNode("2", "Some changes"), CommitNode("3", "Some more changes"), CommitNode("4", "Yet more changes"), CommitNode("5", "Changes galore")), tags = listOf("v1.0", "v1.2", "v1.5"), branches = mapOf("master" to 5)) },
    validator = repoPredicate { repo -> repo.headBranch == "tags/v1.2" || repo.branches.keys.any { "detached at v1.2" in it } },
    testCases = listOf(
        levelTestCase("checkout tag", "git checkout v1.2"),
        levelTestCase("checkout explicit tag", "git checkout tags/v1.2"),
    ),
)
