- 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
32 lines
1.7 KiB
Kotlin
32 lines
1.7 KiB
Kotlin
package solutions.tretter.githugandroid
|
|
|
|
/**
|
|
* Port of the upstream ruby-githug `reset` 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 resetLevel(): Level = level(
|
|
id = "reset",
|
|
title = "Reset",
|
|
description = "There are two files to be committed. The goal was to add each file as a separate commit, however both were added by accident. Unstage the file `to_commit_second.rb` using the reset command (don't commit anything).",
|
|
hints = listOf("git status will tell you the command you need to run."),
|
|
commandSuggestions = listOf("git reset to_commit_second.rb"),
|
|
setup = { RepoState(initialized = true, files = listOf(GitFile("to_commit_first.rb", staged = true), GitFile("to_commit_second.rb", staged = true), GitFile("README", tracked = true)), commits = listOf(CommitNode("0000001", "Initial commit")), branches = mapOf("master" to 1)) },
|
|
nativeSetup = {
|
|
resetFiles()
|
|
write("README")
|
|
addCommit("Initial commit", "README")
|
|
write("to_commit_first.rb")
|
|
write("to_commit_second.rb")
|
|
add("to_commit_first.rb", "to_commit_second.rb")
|
|
true
|
|
},
|
|
validator = repoPredicate { repo -> repo.commits.size == 1 && repo.files.any { it.name == "to_commit_first.rb" && it.staged } && repo.files.any { it.name == "to_commit_second.rb" && !it.staged } },
|
|
testCases = listOf(
|
|
levelTestCase("reset path", "git reset to_commit_second.rb"),
|
|
levelTestCase("restore staged path", "git restore --staged to_commit_second.rb"),
|
|
),
|
|
)
|