Misc Changes
This commit is contained in:
@@ -19,8 +19,8 @@ android {
|
|||||||
applicationId = "solutions.tretter.githugandroid"
|
applicationId = "solutions.tretter.githugandroid"
|
||||||
minSdk = 26
|
minSdk = 26
|
||||||
targetSdk = 35
|
targetSdk = 35
|
||||||
versionCode = 133
|
versionCode = 134
|
||||||
versionName = "0.1.132"
|
versionName = "0.1.133"
|
||||||
|
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
vectorDrawables.useSupportLibrary = true
|
vectorDrawables.useSupportLibrary = true
|
||||||
|
|||||||
@@ -740,7 +740,8 @@ class GitRepositoryRuntime private constructor(
|
|||||||
"fetch" -> {
|
"fetch" -> {
|
||||||
val remote = tokens.getOrNull(2)?.takeIf { !it.startsWith("-") } ?: "origin"
|
val remote = tokens.getOrNull(2)?.takeIf { !it.startsWith("-") } ?: "origin"
|
||||||
inspectedRepo.copy(
|
inspectedRepo.copy(
|
||||||
fetchedBranches = inspectedRepo.fetchedBranches + previousRepo.fetchedBranches + "$remote/master" + "$remote/feature_branch",
|
fetchedBranches = inspectedRepo.fetchedBranches + previousRepo.fetchedBranches + "$remote/master" + "$remote/feature_branch" + "$remote/new_branch",
|
||||||
|
maintenanceActions = inspectedRepo.maintenanceActions + previousRepo.maintenanceActions + "fetch",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
"pull" -> {
|
"pull" -> {
|
||||||
@@ -788,7 +789,7 @@ class GitRepositoryRuntime private constructor(
|
|||||||
maintenanceActions = if ("--squash" in tokens) {
|
maintenanceActions = if ("--squash" in tokens) {
|
||||||
inspectedRepo.maintenanceActions + previousRepo.maintenanceActions + "merge-squash"
|
inspectedRepo.maintenanceActions + previousRepo.maintenanceActions + "merge-squash"
|
||||||
} else {
|
} else {
|
||||||
inspectedRepo.maintenanceActions + previousRepo.maintenanceActions
|
inspectedRepo.maintenanceActions + previousRepo.maintenanceActions + "merge"
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
else -> inspectedRepo.copy(
|
else -> inspectedRepo.copy(
|
||||||
|
|||||||
@@ -62,7 +62,10 @@ object GitSandboxEngine {
|
|||||||
}
|
}
|
||||||
parts.size >= 2 && parts[1] == "fetch" -> {
|
parts.size >= 2 && parts[1] == "fetch" -> {
|
||||||
val remote = parts.getOrNull(2)?.takeIf { !it.startsWith("-") } ?: "origin"
|
val remote = parts.getOrNull(2)?.takeIf { !it.startsWith("-") } ?: "origin"
|
||||||
repo.copy(fetchedBranches = repo.fetchedBranches + listOf("$remote/master", "$remote/feature_branch")) to emptyList()
|
repo.copy(
|
||||||
|
fetchedBranches = repo.fetchedBranches + listOf("$remote/master", "$remote/feature_branch", "$remote/new_branch"),
|
||||||
|
maintenanceActions = repo.maintenanceActions + "fetch",
|
||||||
|
) to emptyList()
|
||||||
}
|
}
|
||||||
parts.size >= 2 && parts[1] == "pull" -> {
|
parts.size >= 2 && parts[1] == "pull" -> {
|
||||||
val remote = parts.getOrNull(2)?.takeIf { !it.startsWith("-") } ?: "origin"
|
val remote = parts.getOrNull(2)?.takeIf { !it.startsWith("-") } ?: "origin"
|
||||||
@@ -454,7 +457,7 @@ object GitSandboxEngine {
|
|||||||
}
|
}
|
||||||
return repo.copy(
|
return repo.copy(
|
||||||
files = files,
|
files = files,
|
||||||
maintenanceActions = if (squash) repo.maintenanceActions + "merge-squash" else repo.maintenanceActions,
|
maintenanceActions = repo.maintenanceActions + if (squash) "merge-squash" else "merge",
|
||||||
) to emptyList()
|
) to emptyList()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,11 @@ internal fun fetchLevel(): Level = level(
|
|||||||
git("branch", "--set-upstream-to=origin/master", "master")
|
git("branch", "--set-upstream-to=origin/master", "master")
|
||||||
true
|
true
|
||||||
},
|
},
|
||||||
validator = repoPredicate { repo -> "origin/new_branch" in repo.fetchedBranches && repo.headBranch == "master" },
|
validator = repoPredicate { repo ->
|
||||||
|
"fetch" in repo.maintenanceActions &&
|
||||||
|
"origin/new_branch" in repo.fetchedBranches &&
|
||||||
|
repo.headBranch == "master"
|
||||||
|
},
|
||||||
testCases = listOf(
|
testCases = listOf(
|
||||||
levelTestCase("fetch origin", "git fetch origin"),
|
levelTestCase("fetch origin", "git fetch origin"),
|
||||||
levelTestCase("fetch default", "git fetch"),
|
levelTestCase("fetch default", "git fetch"),
|
||||||
|
|||||||
@@ -24,7 +24,11 @@ internal fun mergeLevel(): Level = level(
|
|||||||
checkout("master")
|
checkout("master")
|
||||||
true
|
true
|
||||||
},
|
},
|
||||||
validator = repoPredicate { repo -> repo.files.any { it.name == "file2" && it.tracked } },
|
validator = repoPredicate { repo ->
|
||||||
|
repo.headBranch == "master" &&
|
||||||
|
"merge" in repo.maintenanceActions &&
|
||||||
|
repo.files.any { it.name == "file2" && it.tracked }
|
||||||
|
},
|
||||||
testCases = listOf(
|
testCases = listOf(
|
||||||
levelTestCase("merge feature", "git merge feature"),
|
levelTestCase("merge feature", "git merge feature"),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ internal fun statusLevel(): Level = level(
|
|||||||
description = "Among the files in this repository, which of them is untracked?",
|
description = "Among the files in this repository, which of them is untracked?",
|
||||||
hints = listOf("You are looking for a command to identify the status of the repository."),
|
hints = listOf("You are looking for a command to identify the status of the repository."),
|
||||||
commandSuggestions = listOf("git status"),
|
commandSuggestions = listOf("git status"),
|
||||||
setup = { RepoState(initialized = true, files = listOf(GitFile("database.yml"), GitFile("README", tracked = true)), branches = mapOf("master" to 0)) },
|
setup = { RepoState(initialized = true, files = listOf(GitFile("database.yml")), branches = mapOf("master" to 0)) },
|
||||||
validator = commandAnswer("database.yml"),
|
validator = commandAnswer("database.yml"),
|
||||||
testCases = listOf(
|
testCases = listOf(
|
||||||
levelTestCase("answer untracked file", "database.yml"),
|
levelTestCase("answer untracked file", "database.yml"),
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package solutions.tretter.githugandroid
|
package solutions.tretter.githugandroid
|
||||||
|
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
|
import org.junit.Assert.assertFalse
|
||||||
import org.junit.Assert.assertTrue
|
import org.junit.Assert.assertTrue
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import java.io.File
|
import java.io.File
|
||||||
@@ -97,6 +98,30 @@ class LevelSolutionsTest {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun reportedRegressionCommandsDoNotSolveLevels() {
|
||||||
|
val statusRepo = statusLevel().setup()
|
||||||
|
assertEquals(listOf("database.yml"), statusRepo.files.map { it.name })
|
||||||
|
|
||||||
|
val gitBinary = testGitBinary()
|
||||||
|
val runtimeRoot = testSandboxRoot().apply {
|
||||||
|
deleteRecursively()
|
||||||
|
mkdirs()
|
||||||
|
}
|
||||||
|
|
||||||
|
val mergeExercise = mergeLevel()
|
||||||
|
val mergeRuntime = GitRepositoryRuntime(runtimeRoot, gitBinary)
|
||||||
|
val mergeRepo = mergeRuntime.prepareLevel(mergeExercise)
|
||||||
|
val (switchedRepo, _) = mergeRuntime.execute(mergeExercise, mergeRepo, "git switch feature")
|
||||||
|
assertFalse("Switching to feature must not solve the merge level.", mergeExercise.validator(switchedRepo, "git switch feature"))
|
||||||
|
|
||||||
|
val fetchExercise = fetchLevel()
|
||||||
|
val fetchRuntime = GitRepositoryRuntime(runtimeRoot, gitBinary)
|
||||||
|
val fetchRepo = fetchRuntime.prepareLevel(fetchExercise)
|
||||||
|
val (pulledRepo, _) = fetchRuntime.execute(fetchExercise, fetchRepo, "git pull")
|
||||||
|
assertFalse("Pulling must not solve the fetch level.", fetchExercise.validator(pulledRepo, "git pull"))
|
||||||
|
}
|
||||||
|
|
||||||
private companion object {
|
private companion object {
|
||||||
fun writeEvidenceLog(content: String) {
|
fun writeEvidenceLog(content: String) {
|
||||||
val repoRoot = File(System.getProperty("user.dir") ?: ".")
|
val repoRoot = File(System.getProperty("user.dir") ?: ".")
|
||||||
|
|||||||
Reference in New Issue
Block a user