Support interactive add/stage input flow
This commit is contained in:
@@ -129,6 +129,20 @@ class GitRepositoryRuntime private constructor(
|
||||
val shellTokens = GitSandboxEngine.tokenizeShellCommand(command)
|
||||
val tokens = shellTokens.map { it.value }
|
||||
if (tokens.isEmpty()) return inspectSandbox(level).copy(currentDir = currentRepo.currentDir) to emptyList()
|
||||
if (currentRepo.interactiveAddSession != null) {
|
||||
val (updatedRepo, output) = GitSandboxEngine.execute(currentRepo, command)
|
||||
val newlyStagedPaths = updatedRepo.files.filter { updatedFile ->
|
||||
updatedFile.staged && currentRepo.files.firstOrNull { it.name == updatedFile.name }?.staged != true
|
||||
}.map { it.name }
|
||||
if (newlyStagedPaths.isNotEmpty()) {
|
||||
runGit(nativeGit, workingDir, listOf("add") + newlyStagedPaths)
|
||||
}
|
||||
val inspectedRepo = inspectSandbox(level).copy(
|
||||
currentDir = updatedRepo.currentDir,
|
||||
interactiveAddSession = updatedRepo.interactiveAddSession,
|
||||
)
|
||||
return augmentObservedRepoFacts(updatedRepo, inspectedRepo, tokens) to output
|
||||
}
|
||||
val expandedTokens = if (tokens.firstOrNull() == "echo") {
|
||||
tokens
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user