package solutions.tretter.githugandroid

/**
 * Port of the upstream ruby-githug `push_branch` 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 pushBranchLevel(): Level = level(
    id = "push_branch",
    title = "Push Branch",
    description = "You've made some changes to a local branch and want to share it, but aren't yet ready to merge it with the 'master' branch. Push only 'test_branch' to the remote repository",
    hints = listOf("Investigate the options in `git push` using `git push --help`"),
    commandSuggestions = listOf("git push origin test_branch"),
    setup = { RepoState(initialized = true, branches = mapOf("master" to 2, "other_branch" to 3, "test_branch" to 4), remotes = mapOf("origin" to "remote"), headBranch = "master") },
    validator = repoPredicate { repo -> "origin/test_branch" in repo.pushedBranches && "origin/master" !in repo.pushedBranches && "origin/other_branch" !in repo.pushedBranches },
    testCases = listOf(
        levelTestCase("push named branch", "git push origin test_branch"),
        levelTestCase("push current branch refspec", "git push origin test_branch:test_branch"),
    ),
)
