feat: enhance commit generation with temperature setting and confirmation prompt
This commit is contained in:
parent
1bdbf478e3
commit
b122696cab
@ -33,6 +33,7 @@ def gen_commit(project_path):
|
|||||||
agent.llm.model = "gpt-4o"
|
agent.llm.model = "gpt-4o"
|
||||||
agent.auto_run = True
|
agent.auto_run = True
|
||||||
agent.verbose = False
|
agent.verbose = False
|
||||||
|
agent.llm.temperature = 0.3
|
||||||
convention_path = os.path.join(
|
convention_path = os.path.join(
|
||||||
os.path.dirname(__file__), "resources/commit_convention.md"
|
os.path.dirname(__file__), "resources/commit_convention.md"
|
||||||
)
|
)
|
||||||
@ -191,8 +192,7 @@ async def commit_and_push_submodules():
|
|||||||
def format_tree_output(project_path, base_name, base_diff, submodule_diffs, commit):
|
def format_tree_output(project_path, base_name, base_diff, submodule_diffs, commit):
|
||||||
"""Format the output in a tree structure."""
|
"""Format the output in a tree structure."""
|
||||||
|
|
||||||
|
output = [f"📁 {base_name}"]
|
||||||
output = [f"📦 {base_name}"]
|
|
||||||
output.append(f" └── 📝 {commit[project_path]}:")
|
output.append(f" └── 📝 {commit[project_path]}:")
|
||||||
output.append(f" └── 📦 {base_diff}")
|
output.append(f" └── 📦 {base_diff}")
|
||||||
|
|
||||||
@ -235,7 +235,6 @@ async def push_code():
|
|||||||
remote_url = f"https://{git_user}:{git_pass}@{git_repo}"
|
remote_url = f"https://{git_user}:{git_pass}@{git_repo}"
|
||||||
|
|
||||||
await commit_and_push_submodules()
|
await commit_and_push_submodules()
|
||||||
|
|
||||||
commit_msg = gen_commit(project_path)
|
commit_msg = gen_commit(project_path)
|
||||||
commit[project_path] = commit_msg
|
commit[project_path] = commit_msg
|
||||||
print(f"Generated commit message:\n{commit_msg}\n")
|
print(f"Generated commit message:\n{commit_msg}\n")
|
||||||
@ -260,11 +259,26 @@ async def push_code():
|
|||||||
print(stderr.decode())
|
print(stderr.decode())
|
||||||
|
|
||||||
# Format and print the tree output
|
# Format and print the tree output
|
||||||
tree_output = format_tree_output(project_path, base_name, base_diff, submodule_diffs, commit)
|
tree_output = format_tree_output(
|
||||||
|
project_path, base_name, base_diff, submodule_diffs, commit
|
||||||
|
)
|
||||||
print("\nProject Status:")
|
print("\nProject Status:")
|
||||||
print(tree_output)
|
print(tree_output)
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
|
||||||
|
def confirm_commit(project_path, base_name, base_diff):
|
||||||
|
tree_output = format_tree_output(
|
||||||
|
project_path, base_name, base_diff, submodule_diffs, commit
|
||||||
|
)
|
||||||
|
print("\nProject Status:")
|
||||||
|
print(tree_output)
|
||||||
|
print()
|
||||||
|
confirmation = input(
|
||||||
|
"Do you want to commit and push these changes? (y/n): "
|
||||||
|
).lower()
|
||||||
|
return confirmation in ["y", "yes"]
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
asyncio.run(push_code())
|
asyncio.run(push_code())
|
||||||
|
Loading…
Reference in New Issue
Block a user