mirror of
https://github.com/All-Hands-AI/OpenHands.git
synced 2026-01-10 07:18:10 -05:00
Replace bash scripts with Python for git operations (#9914)
Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
@@ -133,7 +133,8 @@ class Runtime(FileEditRuntimeMixin):
|
||||
git_provider_tokens: PROVIDER_TOKEN_TYPE | None = None,
|
||||
):
|
||||
self.git_handler = GitHandler(
|
||||
execute_shell_fn=self._execute_shell_fn_git_handler
|
||||
execute_shell_fn=self._execute_shell_fn_git_handler,
|
||||
create_file_fn=self._create_file_fn_git_handler,
|
||||
)
|
||||
self.sid = sid
|
||||
self.event_stream = event_stream
|
||||
@@ -1017,6 +1018,15 @@ fi
|
||||
|
||||
return CommandResult(content=content, exit_code=exit_code)
|
||||
|
||||
def _create_file_fn_git_handler(self, path: str, content: str) -> int:
|
||||
"""
|
||||
This function is used by the GitHandler to execute shell commands.
|
||||
"""
|
||||
obs = self.write(FileWriteAction(path=path, content=content))
|
||||
if isinstance(obs, ErrorObservation):
|
||||
return -1
|
||||
return 0
|
||||
|
||||
def get_git_changes(self, cwd: str) -> list[dict[str, str]] | None:
|
||||
self.git_handler.set_cwd(cwd)
|
||||
changes = self.git_handler.get_git_changes()
|
||||
|
||||
Reference in New Issue
Block a user