package solutions.tretter.githugandroid /** * Port of the upstream ruby-githug `branch_at` 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 branchAtLevel(): Level = level( id = "branch_at", title = "Branch At", description = "You forgot to branch at the previous commit and made a commit on top of it. Create the branch test_branch at the commit before the last.", hints = listOf("Just like creating a branch, but you have to pass an extra argument."), commandSuggestions = listOf("git branch test_branch HEAD~1"), setup = { RepoState(initialized = true, commits = listOf(CommitNode("1", "Adding file1"), CommitNode("2", "Updating file1"), CommitNode("3", "Updating file1 again")), branches = mapOf("master" to 3)) }, nativeSetup = { resetFiles() write("file1") addCommit("Adding file1", "file1") write("file1", "content") addCommit("Updating file1", "file1") append("file1", "\nAdding some more text") addCommit("Updating file1 again", "file1") true }, validator = repoPredicate { repo -> repo.branches["test_branch"] == 2 }, testCases = listOf( levelTestCase("branch at previous commit", "git branch test_branch HEAD~1"), levelTestCase("branch at caret", "git branch test_branch HEAD^"), levelTestCase("branch at explicit master parent", "git branch test_branch master^"), ), )