diff --git a/scripts/interpreter/gen_commit.py b/scripts/interpreter/gen_commit.py index 6da89cc..91481c1 100755 --- a/scripts/interpreter/gen_commit.py +++ b/scripts/interpreter/gen_commit.py @@ -1,6 +1,5 @@ import os import sys -import subprocess from dotenv import load_dotenv from interpreter import OpenInterpreter @@ -17,24 +16,6 @@ def get_git_credentials(): return sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4] -def run_command(command, cwd=None): - """Run a shell command and return the output.""" - try: - result = subprocess.run( - command, - cwd=cwd, - shell=True, - check=True, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - text=True, - ) - return result.stdout.strip() - except subprocess.CalledProcessError as e: - print(f"Command failed: {command}\n{e.stderr}") - return "" - - def gen_commit(project_path): """Use OpenInterpreter to generate a commit message based on git diff.""" @@ -96,6 +77,7 @@ def push_code(): # Change to project path os.chdir(project_path) print(f"Changed to project path: {project_path}") + # Generate commit message commit_msg = gen_commit(project_path) print(f"Generated commit message:\n{commit_msg}\n") @@ -103,10 +85,11 @@ def push_code(): # Pull, add, commit, and push remote_url = f"https://{git_user}:{git_pass}@{git_repo}" - run_command(f"git pull {remote_url} || true") - run_command("git add .") - run_command(f'git commit -m "{commit_msg}" || true') - run_command(f"git push {remote_url} || true") + # Execute git commands in sequence + os.system(f"git pull {remote_url} || true") + os.system("git add .") + os.system(f'git commit -m "{commit_msg}" || true') + os.system(f"git push {remote_url} || true") if __name__ == "__main__":