package solutions.tretter.githugandroid /** * Port of the upstream ruby-githug `cherry-pick` 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 cherryPickLevel(): Level = level( id = "cherry-pick", title = "Cherry Pick", description = "Your new feature isn't worth the time and you're going to delete it. But it has one commit that fills in `README` file, and you want this commit to be on the master as well.", hints = listOf("Sneak a peek at the `git help cherry-pick` command."), commandSuggestions = listOf("git log --oneline new-feature", "git cherry-pick new-feature"), setup = { RepoState(initialized = true, files = listOf(GitFile("nokia.js", tracked = true)), commits = listOf(CommitNode("1", "Added fancy branded output"), CommitNode("2", "Filled in README.md with proper input")), branches = mapOf("master" to 1, "new-feature" to 2)) }, validator = repoPredicate { repo -> repo.files.any { it.name == "README.md" && it.tracked } && repo.headBranch == "master" && repo.commits.take(2).map { it.message } == listOf("Filled in README.md with proper input", "Added fancy branded output") }, nativeSetup = { resetFiles() write("nokia.js", "console.log('Nokia tune')\n") addCommit("Added fancy branded output", "nokia.js") checkoutNew("new-feature") write("README.md", "Proper input instructions\n") addCommit("Filled in README.md with proper input", "README.md") checkout("master") git("branch", "-f", "feature", "new-feature") true }, testCases = listOf( levelTestCase("cherry pick new feature tip", "git cherry-pick new-feature"), levelTestCase("cherry pick feature alias", "git cherry-pick feature"), ), )