Open patch hunk editor for git add -p edit command
This commit is contained in:
@@ -315,6 +315,21 @@ class GitRepositoryRuntime private constructor(
|
||||
return executeInteractiveRebaseEditorCommand(level, currentRepo, nativeGit, sandboxRoot, workingDir, invocation, message)
|
||||
}
|
||||
|
||||
if (invocation.kind == GitEditorCommandKind.PATCH_HUNK) {
|
||||
val (updatedRepo, output) = GitSandboxEngine.applyPatchHunkEdit(currentRepo, message)
|
||||
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 inspectedRepo to output
|
||||
}
|
||||
|
||||
val messageFile = File(sandboxRoot, ".git/GITHUG_ANDROID_EDITMSG").apply {
|
||||
parentFile?.mkdirs()
|
||||
writeText(message)
|
||||
|
||||
Reference in New Issue
Block a user