Misc Changes
This commit is contained in:
@@ -65,9 +65,14 @@ class GitRepositoryRuntime(private val context: Context) {
|
||||
val workingDir = File(sandboxRoot, currentRepo.currentDir).canonicalFile
|
||||
.takeIf { it.path.startsWith(sandboxRoot.path) } ?: sandboxRoot
|
||||
|
||||
val tokens = GitSandboxEngine.tokenizeCommand(command)
|
||||
val shellTokens = GitSandboxEngine.tokenizeShellCommand(command)
|
||||
val tokens = shellTokens.map { it.value }
|
||||
if (tokens.isEmpty()) return inspectSandbox(level).copy(currentDir = currentRepo.currentDir) to emptyList()
|
||||
val expandedTokens = expandShellPathspecs(currentRepo, tokens)
|
||||
val expandedTokens = if (tokens.firstOrNull() == "echo") {
|
||||
tokens
|
||||
} else {
|
||||
expandShellPathspecs(currentRepo, shellTokens)
|
||||
}
|
||||
|
||||
val result = when (expandedTokens.first()) {
|
||||
"git" -> currentRepo to runGit(nativeGit, workingDir, expandedTokens.drop(1)).outputLines
|
||||
@@ -536,9 +541,9 @@ class GitRepositoryRuntime(private val context: Context) {
|
||||
|
||||
private fun sandboxDir(level: Level): File = File(sandboxesRoot, level.id)
|
||||
|
||||
private fun expandShellPathspecs(repo: RepoState, tokens: List<String>): List<String> {
|
||||
if (tokens.size <= 1) return tokens
|
||||
return listOf(tokens.first()) + GitSandboxEngine.expandPathspecs(repo, tokens.drop(1))
|
||||
private fun expandShellPathspecs(repo: RepoState, tokens: List<GitSandboxEngine.ShellToken>): List<String> {
|
||||
if (tokens.size <= 1) return tokens.map { it.value }
|
||||
return listOf(tokens.first().value) + GitSandboxEngine.expandPathspecTokens(repo, tokens.drop(1))
|
||||
}
|
||||
|
||||
private fun runGit(binary: File, workingDir: File, arguments: List<String>): ProcessExecutionResult {
|
||||
|
||||
Reference in New Issue
Block a user