package solutions.tretter.githugandroid

/**
 * Port of the upstream ruby-githug `stage_lines` 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 stageLinesLevel(): Level = level(
    id = "stage_lines",
    title = "Stage Lines",
    description = "You've made changes within a single file that belong to two different features, but neither of the changes are yet staged. Stage only the changes belonging to the first feature.",
    hints = listOf("Read about the flags which can be passed to the `add` command."),
    commandSuggestions = listOf("git add feature.rb"),
    setup = { RepoState(initialized = true, files = listOf(GitFile("feature.rb", "this is the class of my feature\nThis change belongs to the first feature\nThis change belongs to the second feature", tracked = true)), branches = mapOf("master" to 1)) },
    nativeSetup = {
        resetFiles()
        write("feature.rb", "this is the class of my feature\n")
        addCommit("Initial feature", "feature.rb")
        write("feature.rb", "this is the class of my feature\nThis change belongs to the first feature\nThis change belongs to the second feature")
        true
    },
    validator = repoPredicate { repo -> repo.files.any { it.name == "feature.rb" && it.staged } },
    testCases = listOf(
        levelTestCase("stage feature file", "git add feature.rb"),
    ),
)
