- 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
24 lines
1.5 KiB
Kotlin
24 lines
1.5 KiB
Kotlin
package solutions.tretter.githugandroid
|
|
|
|
/**
|
|
* Port of the upstream ruby-githug `commit_amend` 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 commitAmendLevel(): Level = level(
|
|
id = "commit_amend",
|
|
title = "Commit Amend",
|
|
description = "The `README` file has been committed, but it looks like the file `forgotten_file.rb` was missing from the commit. Add the file and amend your previous commit to include it.",
|
|
hints = listOf("Running `git commit --help` will display the man page and possible flags."),
|
|
commandSuggestions = listOf("git add forgotten_file.rb", "git commit --amend --no-edit"),
|
|
setup = { RepoState(initialized = true, files = listOf(GitFile("README", tracked = true), GitFile("forgotten_file.rb")), commits = listOf(CommitNode("0000001", "Initial commit")), branches = mapOf("master" to 1)) },
|
|
validator = repoPredicate { repo -> repo.commits.size == 1 && repo.files.any { it.name == "forgotten_file.rb" && it.tracked && !it.staged } },
|
|
testCases = listOf(
|
|
levelTestCase("amend after add", "git add forgotten_file.rb", "git commit --amend --no-edit"),
|
|
levelTestCase("amend with message option", "git add forgotten_file.rb", "git commit --amend -m \"Initial commit\""),
|
|
levelTestCase("amend through editor", "git add forgotten_file.rb", "GIT_EDITOR=true git commit --amend"),
|
|
),
|
|
)
|