- 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
46 lines
1.9 KiB
Kotlin
46 lines
1.9 KiB
Kotlin
package solutions.tretter.githugandroid
|
|
|
|
import java.io.File
|
|
|
|
/**
|
|
* Port of the upstream ruby-githug `pull` 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 pullLevel(): Level = level(
|
|
id = "pull",
|
|
title = "Pull",
|
|
description = "You need to pull changes from your origin repository.",
|
|
hints = listOf("Check out the remote repositories and research `git pull`."),
|
|
commandSuggestions = listOf("git pull origin master"),
|
|
setup = { RepoState(initialized = true, remotes = mapOf("origin" to "remote"), branches = mapOf("master" to 1)) },
|
|
nativeSetup = {
|
|
resetFiles()
|
|
write("local_file")
|
|
addCommit("Initial local commit", "local_file")
|
|
val remote = siblingRepo("origin")
|
|
git("remote", "add", "pull-setup-origin", File(remote, ".git").absolutePath)
|
|
git("push", "pull-setup-origin", "master")
|
|
git("remote", "remove", "pull-setup-origin")
|
|
git(remote, "checkout", "-f", "master")
|
|
writeIn(remote, "remote_file", "pulled from origin\n")
|
|
addCommitIn(remote, "Pulled commit", "remote_file")
|
|
git("remote", "add", "origin", File(remote, ".git").absolutePath)
|
|
git("config", "branch.master.remote", "origin")
|
|
git("config", "branch.master.merge", "refs/heads/master")
|
|
true
|
|
},
|
|
validator = repoPredicate { repo ->
|
|
"origin/master" in repo.fetchedBranches &&
|
|
repo.files.any { it.name == "remote_file" && it.tracked } &&
|
|
repo.commits.size >= 2
|
|
},
|
|
testCases = listOf(
|
|
levelTestCase("pull explicit remote branch", "git pull origin master"),
|
|
levelTestCase("pull default origin", "git pull"),
|
|
levelTestCase("fetch then merge", "git fetch origin", "git merge origin/master"),
|
|
),
|
|
)
|