diff --git a/registry.mk b/registry.mk index 8d676a8..350bd22 100644 --- a/registry.mk +++ b/registry.mk @@ -3,11 +3,7 @@ REGISTRY_REPO = git.nextzenos.com/CDN/bifrost-registry.git PYTHON = $(REGISTRY_PATH)/venv/bin/python update_registry: package_registry upload_registry clean_registry ( cd $(REGISTRY_PATH) && \ - read -p "Enter your commit message for registry submodule: " commit_registry_msg; \ - git pull https://$(GIT_USER):$(GIT_PASS)@$(REGISTRY_REPO) || true; \ - git add . && \ - git commit -m "$${commit_registry_msg:-update}" || true; \ - git push https://$(GIT_USER):$(GIT_PASS)@$(REGISTRY_REPO) || true ) + $(PYTHON) $(REGISTRY_PATH)/scripts/interpreter/gen_commit.py $(GIT_USER) $(GIT_PASS) $(REGISTRY_REPO) ) package_registry: (cd $(REGISTRY_PATH) && \ diff --git a/requirement.txt b/requirement.txt index 0a7efc4..0c9c50c 100644 --- a/requirement.txt +++ b/requirement.txt @@ -1,2 +1,3 @@ python-dotenv ; python_version > '3.10' -git+https://github.com/dblueai/giteapy.git ; python_version > '3.10' \ No newline at end of file +git+https://github.com/dblueai/giteapy.git ; python_version > '3.10' +open-interpreter ; python_version > '3.10' \ No newline at end of file diff --git a/scripts/interpreter/gen_commit.py b/scripts/interpreter/gen_commit.py index c739644..c0c8ed1 100755 --- a/scripts/interpreter/gen_commit.py +++ b/scripts/interpreter/gen_commit.py @@ -1,9 +1,18 @@ from interpreter import OpenInterpreter import os +import sys from dotenv import load_dotenv load_dotenv() + +def get_git_credentials(): + if len(sys.argv) != 4: + print("Usage: python gen_commit.py ") + sys.exit(1) + return sys.argv[1], sys.argv[2], sys.argv[3] + + def gen_commit(): agent = OpenInterpreter() # Set auto_run to True to always allow code execution @@ -30,47 +39,28 @@ def gen_commit(): - merge: merge the code - conflict: resolve the conflict - other: other - How to show uncommitted changes in Git - - The command you are looking for is git diff. - - git diff - Show changes between commits, commit and working tree, etc - - Here are some of the options it expose which you can use - - git diff (no parameters) - Print out differences between your working directory and the index. - - git diff --cached: - Print out differences between the index and HEAD (current commit). - - git diff HEAD: - Print out differences between your working directory and the HEAD. - - git diff --name-only - Show only names of changed files. - - git diff --name-status - Show only names and status of changed files. - - git diff --color-words - Word by word diff instead of line by line. + 4. Only return the commit message in markdown format, no other text or explanation. """ response = agent.chat( """ Generate a commit message for the uncommit code in project path /root/dev/Bifrost - You should change working directory to /root/dev/Bifrost + You should change working directory to /root/dev/Bifrost and use git diff --name-status to get the changes """ ) - return response + # Extract just the content from the response + if isinstance(response, list) and len(response) > 0: + if isinstance(response[0], dict) and 'content' in response[0]: + return response[0]['content'] + return str(response) def push_code(): + git_user, git_pass, git_repo = get_git_credentials() commit_msg = gen_commit() - os.system(f'git pull https://{os.getenv("GIT_USER")}:{os.getenv("GIT_PASS")}@{os.getenv("GIT_REPO")} || true') - os.system('git add .') + os.system(f"git pull https://{git_user}:{git_pass}@{git_repo} || true") + os.system("git add .") os.system(f'git commit -m "{commit_msg}" || true') - os.system(f'git push https://{os.getenv("GIT_USER")}:{os.getenv("GIT_PASS")}@{os.getenv("GIT_REPO")} || true') + os.system(f"git push https://{git_user}:{git_pass}@{git_repo} || true") if __name__ == "__main__":