-
Notifications
You must be signed in to change notification settings - Fork 0
/
branch_name.py
25 lines (22 loc) · 1.06 KB
/
branch_name.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import asyncio
import subprocess
from async_openai_client import AsyncOpenAIClient
async def generate_branch_name(user_input):
client = AsyncOpenAIClient()
while True:
prompt = "You're an expert developer, generate a good branch name (LOWERCASE, respect git standards) for the following task: \n\n" + user_input
branch_name = await client.generate_response(prompt)
print(branch_name)
# Confirm the branch name
confirm = input("\n\n Is this branch name okay? (Y/n): ")
if confirm.lower() in ['y', 'yes']:
# Execute Git command to checkout new branch
subprocess.run(["git", "checkout", "-b", branch_name])
break # Exit loop after successful branch creation
else:
# Ask for user input again
print("Please provide a new description for the branch.")
user_input = input("Branch description: ")
if __name__ == "__main__":
user_input = input("Please provide a description for the branch: ")
asyncio.run(generate_branch_name(user_input))