Files
Githug-Android/app/src/main/java/solutions/tretter/githugandroid/levels/CheckoutFileLevel.kt
Joe Tretter 64743ff4a9 Move native level setups into level files
- Delete NativeLevelFixtures.kt and make native repository setup an optional property of each Level.
- Move every existing native setup into its corresponding level file so setup, validation, and tests stay together.
- Add the missing Blame native setup with config.rb history and a Spider Man password commit.
- Add a native runtime regression that verifies `git blame config.rb` identifies Spider Man on the password line.
- Verify the full JVM test suite using the compiled host Git runtime.
2026-05-07 18:53:18 -05:00

29 lines
1.5 KiB
Kotlin

package solutions.tretter.githugandroid
/**
* Port of the upstream ruby-githug `checkout_file` 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 checkoutFileLevel(): Level = level(
id = "checkout_file",
title = "Checkout File",
description = "A file has been modified, but you don't want to keep the modification. Checkout the `config.rb` file from the last commit.",
hints = listOf("You will need to do some research on the checkout command for this one."),
commandSuggestions = listOf("git checkout -- config.rb"),
setup = { RepoState(initialized = true, files = listOf(GitFile("config.rb", "This is the initial config file\nThese are changes you don't want to keep!", tracked = true)), commits = listOf(CommitNode("0000001", "Added initial config file")), branches = mapOf("master" to 1)) },
nativeSetup = {
resetFiles()
write("config.rb", "This is the initial config file")
addCommit("Added initial config file", "config.rb")
append("config.rb", "\nThese are changes you don't want to keep!")
true
},
validator = repoPredicate { repo -> repo.files.find { it.name == "config.rb" }?.content == "This is the initial config file" },
testCases = listOf(
levelTestCase("checkout file from head", "git checkout -- config.rb"),
),
)