Misc Changes

This commit is contained in:
Joe Tretter
2026-05-11 19:19:51 -05:00
parent 8f829fb969
commit 7e55084815
7 changed files with 46 additions and 9 deletions

View File

@@ -740,7 +740,8 @@ class GitRepositoryRuntime private constructor(
"fetch" -> {
val remote = tokens.getOrNull(2)?.takeIf { !it.startsWith("-") } ?: "origin"
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" -> {
@@ -788,7 +789,7 @@ class GitRepositoryRuntime private constructor(
maintenanceActions = if ("--squash" in tokens) {
inspectedRepo.maintenanceActions + previousRepo.maintenanceActions + "merge-squash"
} else {
inspectedRepo.maintenanceActions + previousRepo.maintenanceActions
inspectedRepo.maintenanceActions + previousRepo.maintenanceActions + "merge"
},
)
else -> inspectedRepo.copy(

View File

@@ -62,7 +62,10 @@ object GitSandboxEngine {
}
parts.size >= 2 && parts[1] == "fetch" -> {
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" -> {
val remote = parts.getOrNull(2)?.takeIf { !it.startsWith("-") } ?: "origin"
@@ -454,7 +457,7 @@ object GitSandboxEngine {
}
return repo.copy(
files = files,
maintenanceActions = if (squash) repo.maintenanceActions + "merge-squash" else repo.maintenanceActions,
maintenanceActions = repo.maintenanceActions + if (squash) "merge-squash" else "merge",
) to emptyList()
}

View File

@@ -32,7 +32,11 @@ internal fun fetchLevel(): Level = level(
git("branch", "--set-upstream-to=origin/master", "master")
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(
levelTestCase("fetch origin", "git fetch origin"),
levelTestCase("fetch default", "git fetch"),

View File

@@ -24,7 +24,11 @@ internal fun mergeLevel(): Level = level(
checkout("master")
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(
levelTestCase("merge feature", "git merge feature"),
),

View File

@@ -13,7 +13,7 @@ internal fun statusLevel(): Level = level(
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."),
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"),
testCases = listOf(
levelTestCase("answer untracked file", "database.yml"),