update: modify registry.mk and gen_commit.py in scripts/interpreter
This commit is contained in:
+1
-1
@@ -3,7 +3,7 @@ REGISTRY_REPO = git.nextzenos.com/CDN/bifrost-registry.git
|
|||||||
PYTHON = $(REGISTRY_PATH)/venv/bin/python
|
PYTHON = $(REGISTRY_PATH)/venv/bin/python
|
||||||
update_registry: package_registry upload_registry clean_registry
|
update_registry: package_registry upload_registry clean_registry
|
||||||
( cd $(REGISTRY_PATH) && \
|
( cd $(REGISTRY_PATH) && \
|
||||||
$(PYTHON) $(REGISTRY_PATH)/scripts/interpreter/gen_commit.py $(GIT_USER) $(GIT_PASS) $(REGISTRY_REPO) )
|
$(PYTHON) $(REGISTRY_PATH)/scripts/interpreter/gen_commit.py $(GIT_USER) $(GIT_PASS) $(REGISTRY_REPO) $(REGISTRY_PATH) )
|
||||||
|
|
||||||
package_registry:
|
package_registry:
|
||||||
(cd $(REGISTRY_PATH) && \
|
(cd $(REGISTRY_PATH) && \
|
||||||
|
|||||||
@@ -7,16 +7,19 @@ load_dotenv()
|
|||||||
|
|
||||||
|
|
||||||
def get_git_credentials():
|
def get_git_credentials():
|
||||||
if len(sys.argv) != 4:
|
if len(sys.argv) != 5: # Changed from 4 to 5 to match expected arguments
|
||||||
print("Usage: python gen_commit.py <GIT_USER> <GIT_PASS> <GIT_REPO>")
|
print(
|
||||||
|
"Usage: python gen_commit.py <GIT_USER> <GIT_PASS> <GIT_REPO> <PROJECT_PATH>"
|
||||||
|
)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
return sys.argv[1], sys.argv[2], sys.argv[3]
|
return sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4]
|
||||||
|
|
||||||
|
|
||||||
def gen_commit():
|
def gen_commit(project_path):
|
||||||
agent = OpenInterpreter()
|
agent = OpenInterpreter()
|
||||||
# Set auto_run to True to always allow code execution
|
# Set auto_run to True to always allow code execution
|
||||||
agent.auto_run = True
|
agent.auto_run = True
|
||||||
|
|
||||||
agent.system_message = """
|
agent.system_message = """
|
||||||
Your name is Bifrost,
|
Your name is Bifrost,
|
||||||
you are a helpful assistant that can help me generate a commit message base on umcommit code.
|
you are a helpful assistant that can help me generate a commit message base on umcommit code.
|
||||||
@@ -39,24 +42,27 @@ def gen_commit():
|
|||||||
- merge: merge the code
|
- merge: merge the code
|
||||||
- conflict: resolve the conflict
|
- conflict: resolve the conflict
|
||||||
- other: other
|
- other: other
|
||||||
4. Only return the commit message in markdown format, no other text or explanation.
|
4. Only return the commit message follow Git Commit Style Guide, no other text or explanation.
|
||||||
"""
|
"""
|
||||||
response = agent.chat(
|
response = agent.chat(
|
||||||
"""
|
f"""
|
||||||
Generate a commit message for the uncommit code in project path /root/dev/Bifrost
|
Generate a commit message for the uncommit code in project path {project_path}
|
||||||
You should change working directory to /root/dev/Bifrost and use git diff --name-status to get the changes
|
You should change working directory to {project_path} and use git diff --name-status to get the changes
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
# Extract just the content from the response
|
# Extract just the content from the response
|
||||||
if isinstance(response, list) and len(response) > 0:
|
if isinstance(response, list) and len(response) > 0:
|
||||||
if isinstance(response[0], dict) and 'content' in response[0]:
|
if isinstance(response[-1], dict) and "content" in response[-1]:
|
||||||
return response[0]['content']
|
return response[-1]["content"]
|
||||||
|
|
||||||
return str(response)
|
return str(response)
|
||||||
|
|
||||||
|
|
||||||
def push_code():
|
def push_code():
|
||||||
git_user, git_pass, git_repo = get_git_credentials()
|
git_user, git_pass, git_repo, project_path = get_git_credentials()
|
||||||
commit_msg = gen_commit()
|
commit_msg = gen_commit(project_path)
|
||||||
|
print(commit_msg)
|
||||||
os.system(f"git pull https://{git_user}:{git_pass}@{git_repo} || true")
|
os.system(f"git pull https://{git_user}:{git_pass}@{git_repo} || true")
|
||||||
os.system("git add .")
|
os.system("git add .")
|
||||||
os.system(f'git commit -m "{commit_msg}" || true')
|
os.system(f'git commit -m "{commit_msg}" || true')
|
||||||
|
|||||||
Reference in New Issue
Block a user