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"),
    ),
)
