diff --git a/scripts/interpreter/__init__.py b/scripts/interpreter/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/scripts/interpreter/gen_commit.py b/scripts/interpreter/gen_commit.py new file mode 100755 index 0000000..c739644 --- /dev/null +++ b/scripts/interpreter/gen_commit.py @@ -0,0 +1,77 @@ +from interpreter import OpenInterpreter +import os +from dotenv import load_dotenv + +load_dotenv() + +def gen_commit(): + agent = OpenInterpreter() + # Set auto_run to True to always allow code execution + agent.auto_run = True + agent.system_message = """ + Your name is Bifrost, + you are a helpful assistant that can help me generate a commit message base on umcommit code. + + You should follow these rules: + 1. The commit message should be in English. + 2. The commit message should be concise and to the point. + 3. The commit message should be formatted as follows: + - feat: add a new feature + - fix: fix a bug + - refactor: refactor the code + - chore: update the code + - perf: improve the performance + - test: add a test + - docs: update the docs + - update: update the code + - remove: remove the code + - style: style the code + - revert: revert the code + - 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. + """ + 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 + """ + ) + return response + + +def push_code(): + 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 commit -m "{commit_msg}" || true') + os.system(f'git push https://{os.getenv("GIT_USER")}:{os.getenv("GIT_PASS")}@{os.getenv("GIT_REPO")} || true') + + +if __name__ == "__main__": + push_code()