package solutions.tretter.githugandroid

/**
 * Port of the upstream ruby-githug `commit_in_future` 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 commitInFutureLevel(): Level = level(
    id = "commit_in_future",
    title = "Commit In Future",
    description = "Commit your changes with a date later than the current system date.",
    hints = listOf("Build a future timestamp, and commit your code using the --date parameter."),
    commandSuggestions = listOf("git commit --date 2037-01-01T00:00:00+0000 -m \"Future commit\""),
    setup = { RepoState(initialized = true, files = listOf(GitFile("README", staged = true)), branches = mapOf("master" to 0)) },
    validator = repoPredicate { repo ->
        val nowSeconds = System.currentTimeMillis() / 1000
        repo.commits.any { commit ->
            commit.authorTimestampSeconds?.let { authorTime -> authorTime > nowSeconds } == true
        }
    },
    testCases = listOf(
        levelTestCase("commit with date option", "git commit --date 2037-01-01T00:00:00+0000 -m \"Future commit\""),
    ),
    negativeTestCases = listOf(
        levelTestCase("current date commit does not solve", "git commit -m \"Current date commit\""),
    ),
)
