Remove user message dependency from level validators
This commit is contained in:
@@ -12,7 +12,7 @@ internal fun mergeSquashLevel(): Level = level(
|
||||
title = "Merge Squash",
|
||||
description = "Merge all commits from the long-feature-branch as a single commit.",
|
||||
hints = listOf("Take a look at the `--squash` option of the merge command. Don't forget to commit the merge!"),
|
||||
commandSuggestions = listOf("git merge --squash long-feature-branch", "git commit -m \"Merge long feature\""),
|
||||
commandSuggestions = listOf("git merge --squash long-feature-branch", "git commit -m \"<message>\""),
|
||||
setup = { RepoState(initialized = true, files = listOf(GitFile("file1", tracked = true)), branches = mapOf("master" to 2, "long-feature-branch" to 4)) },
|
||||
nativeSetup = {
|
||||
resetFiles()
|
||||
@@ -31,12 +31,21 @@ internal fun mergeSquashLevel(): Level = level(
|
||||
true
|
||||
},
|
||||
validator = repoPredicate { repo ->
|
||||
repo.commits.firstOrNull()?.message == "Merge long feature" &&
|
||||
repo.headBranch == "master" &&
|
||||
repo.commits.size == 3 &&
|
||||
repo.commits.firstOrNull()?.parentCount == 1 &&
|
||||
repo.files.any { it.name == "file3" && it.tracked }
|
||||
repo.files.any { it.name == "file3" && it.tracked && it.content == mergeSquashLevelFile3Content() }
|
||||
},
|
||||
testCases = listOf(
|
||||
levelTestCase("squash merge then commit", "git merge --squash long-feature-branch", "git commit -m \"Merge long feature\""),
|
||||
levelTestCase("squash no commit then commit", "git merge --squash --no-commit long-feature-branch", "git commit -m \"Merge long feature\""),
|
||||
levelTestCase("squash merge with arbitrary message", "git merge --squash long-feature-branch", "git commit -m \"Any message works\""),
|
||||
levelTestCase("squash no commit then commit", "git merge --squash --no-commit long-feature-branch", "git commit -m \"Finished feature branch\""),
|
||||
),
|
||||
negativeTestCases = listOf(
|
||||
levelTestCase("squash merge without commit", "git merge --squash long-feature-branch"),
|
||||
levelTestCase("regular merge is not a squash", "git merge --no-edit long-feature-branch"),
|
||||
),
|
||||
)
|
||||
|
||||
private fun mergeSquashLevelFile3Content(): String =
|
||||
"some feature\ngetting awesomer\nand awesomer!\n"
|
||||
|
||||
@@ -24,10 +24,20 @@ internal fun revertLevel(): Level = level(
|
||||
addCommit("Second commit", "file2")
|
||||
true
|
||||
},
|
||||
validator = repoPredicate { repo -> repo.commits.any { it.message.startsWith("Revert") } },
|
||||
validator = repoPredicate { repo ->
|
||||
repo.headBranch == "master" &&
|
||||
repo.commits.size >= 4 &&
|
||||
repo.commits.firstOrNull()?.parentCount == 1 &&
|
||||
repo.files.none { it.name == "file3" && !it.deleted } &&
|
||||
repo.commits.map { it.message }.containsAll(listOf("First commit", "Bad commit", "Second commit"))
|
||||
},
|
||||
testCases = listOf(
|
||||
levelTestCase("revert middle commit", "git revert HEAD~1"),
|
||||
levelTestCase("revert middle commit without editor", "git revert --no-edit HEAD~1"),
|
||||
levelTestCase("revert caret commit", "git revert HEAD^"),
|
||||
levelTestCase("revert without commit then arbitrary message", "git revert -n HEAD~1", "git commit -m \"Undo unwanted file\""),
|
||||
),
|
||||
negativeTestCases = listOf(
|
||||
levelTestCase("revert without replacement commit", "git revert -n HEAD~1"),
|
||||
),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user