cd /root/dev/Bifrost && git diff --name-status
This commit is contained in:
@@ -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 <GIT_USER> <GIT_PASS> <GIT_REPO>")
|
||||
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__":
|
||||
|
||||
Reference in New Issue
Block a user