cd /root/dev/Bifrost && git diff --name-status

This commit is contained in:
2025-05-13 18:39:21 +07:00
parent 3983b2902a
commit f8f1823594
3 changed files with 23 additions and 36 deletions

View File

@@ -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) && \

View File

@@ -1,2 +1,3 @@
python-dotenv ; python_version > '3.10'
git+https://github.com/dblueai/giteapy.git ; python_version > '3.10'
git+https://github.com/dblueai/giteapy.git ; python_version > '3.10'
open-interpreter ; python_version > '3.10'

View File

@@ -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__":