package solutions.tretter.githugandroid /** * Port of the upstream ruby-githug `find_old_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 findOldBranchLevel(): Level = level( id = "find_old_branch", title = "Find Old Branch", description = "You have been working on a branch but got distracted by a major issue. Switch back to that branch even though you forgot the name of it.", hints = listOf("Ever played with the `git reflog` command?"), commandSuggestions = listOf("git checkout solve_world_hunger"), setup = { RepoState( initialized = true, headBranch = "master", files = listOf( GitFile("myfile.txt", "THIS TEXT DOESN'T MATTER\n", tracked = true), GitFile("TODO", "FIND THE JOKER\n", tracked = true), ), branches = mapOf( "blowup_sun_for_ransom" to 1, "cure_common_cold" to 1, "master" to 2, "solve_world_hunger" to 2, ), ) }, nativeSetup = { resetFiles() write("myfile.txt", "THIS TEXT DOESN'T MATTER\n") addCommit("initial commit", "myfile.txt") git("branch", "blowup_sun_for_ransom") git("branch", "cure_common_cold") checkoutNew("solve_world_hunger") write("TODO", "FIX WORLD HUNGER\n") addCommit("commit todo", "TODO") checkout("master") write("TODO", "FIND THE JOKER\n") addCommit("commit another todo", "TODO") true }, validator = repoPredicate { repo -> repo.headBranch == "solve_world_hunger" }, testCases = listOf( levelTestCase("checkout old branch", "git checkout solve_world_hunger"), levelTestCase("switch old branch", "git switch solve_world_hunger"), ), setupChecks = listOf( levelSetupCheck( "upstream branch puzzle shape is present", "find_old_branch should start on master with upstream distractor branches and solve_world_hunger.", ) { repo -> repo.headBranch == "master" && repo.branches.keys == setOf("blowup_sun_for_ransom", "cure_common_cold", "master", "solve_world_hunger") }, ), )