Push the selected changes to the remote repository Args: commit_message (str): The commit message file_paths (list): The file paths to commit, if None, commit all changes Returns: dict: The push result
(context_variables, commit_message, file_paths=None)
| 56 | |
| 57 | @register_tool("push_changes") |
| 58 | def push_changes(context_variables, commit_message, file_paths=None): |
| 59 | """ |
| 60 | Push the selected changes to the remote repository |
| 61 | |
| 62 | Args: |
| 63 | commit_message (str): The commit message |
| 64 | file_paths (list): The file paths to commit, if None, commit all changes |
| 65 | |
| 66 | Returns: |
| 67 | dict: The push result |
| 68 | """ |
| 69 | # stage the files |
| 70 | # if file_paths: |
| 71 | env: Union[DockerEnv, LocalEnv] = context_variables.get("code_env", LocalEnv()) |
| 72 | stage_result = stage_files(env, file_paths) |
| 73 | if stage_result['status'] != 0: |
| 74 | return json.dumps({'status': 'error', 'message': f"Failed to stage files: {stage_result['result']}"}, indent=4) |
| 75 | |
| 76 | commands = [ |
| 77 | f"cd {env.docker_workplace}/autoagent", |
| 78 | f'git commit -m "{commit_message}"', |
| 79 | "git push origin $(git branch --show-current)" |
| 80 | ] |
| 81 | |
| 82 | command = " && ".join(commands) |
| 83 | result = env.run_command(command) |
| 84 | |
| 85 | if result['status'] == 0: |
| 86 | return f"push success. {result['result']}" |
| 87 | else: |
| 88 | return f"push failed. {result['result']}" |
| 89 | |
| 90 | @register_tool("submit_pull_request") |
| 91 | def submit_pull_request(title: str, body: str, target_branch: str): |
no test coverage detected