Files
Githug-Android/app/src/main/java/solutions/tretter/githugandroid/levels/CheckoutFileLevel.kt
Joe Tretter 781b5090f7 Fix Git editor reword workflow and UI coverage
- show Git editor file paths instead of the submitted git command
- surface follow-up commit message editors during interactive rebase reword
- add rename-commit UI tests for editor and amend-message solution paths
- add broader embedded level solution scenarios for alternate Git workflows
2026-06-26 11:23:16 -05:00

31 lines
1.7 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"),
levelTestCase("restore file from index", "git restore config.rb"),
levelTestCase("checkout file from explicit head", "git checkout HEAD -- config.rb"),
),
)