- 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
50 lines
2.4 KiB
Kotlin
50 lines
2.4 KiB
Kotlin
package solutions.tretter.githugandroid
|
|
|
|
/**
|
|
* Port of the upstream ruby-githug `rebase_onto` 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 rebaseOntoLevel(): Level = level(
|
|
id = "rebase_onto",
|
|
title = "Rebase Onto",
|
|
description = "You have created your branch from `wrong_branch` and already made some commits, and you realise that you needed to create your branch from `master`. Rebase your commits onto `master` branch so that you don't have `wrong_branch` commits.",
|
|
hints = listOf("You want to research the `git rebase` commands `--onto` argument"),
|
|
commandSuggestions = listOf("git rebase --onto master wrong_branch readme-update"),
|
|
setup = { RepoState(initialized = true, headBranch = "readme-update", branches = mapOf("master" to 1, "wrong_branch" to 2, "readme-update" to 4)) },
|
|
nativeSetup = {
|
|
resetFiles()
|
|
write("authors.md", "https://github.com/janis-vitols\n")
|
|
addCommit("Create authors file", "authors.md")
|
|
checkoutNew("wrong_branch")
|
|
write("authors.md", "None\n")
|
|
addCommit("Wrong changes", "authors.md")
|
|
checkoutNew("readme-update")
|
|
write("README.md", "# SuperApp\n")
|
|
addCommit("Add app name in readme", "README.md")
|
|
append("README.md", "## About\n")
|
|
addCommit("Add `About` header in readme", "README.md")
|
|
append("README.md", "## Install\n")
|
|
addCommit("Add `Install` header in readme", "README.md")
|
|
true
|
|
},
|
|
validator = repoPredicate { repo ->
|
|
repo.headBranch == "readme-update" &&
|
|
repo.files.find { it.name == "authors.md" }?.content == "https://github.com/janis-vitols\n" &&
|
|
repo.commits.map { it.message }.containsAll(
|
|
listOf(
|
|
"Add app name in readme",
|
|
"Add `About` header in readme",
|
|
"Add `Install` header in readme",
|
|
),
|
|
)
|
|
},
|
|
testCases = listOf(
|
|
levelTestCase("rebase onto explicit branch", "git rebase --onto master wrong_branch readme-update"),
|
|
levelTestCase("rebase onto current branch", "git rebase --onto master wrong_branch"),
|
|
levelTestCase("rebase onto full branch ref", "git rebase --onto refs/heads/master wrong_branch readme-update"),
|
|
),
|
|
)
|