Create a new branch following the repository's naming conventions:
- •
Determine branch type:
- •Use AskUserQuestion with options:
- •"Feature branch"
- •"Bug fix branch"
- •"Cleanup branch"
- •Use AskUserQuestion with options:
- •
Analyze repository branch naming conventions:
- •Get recent branch names:
bash
git for-each-ref --sort=-committerdate refs/heads/ --format='%(refname:short)' --count=20
- •Look for patterns like:
- •
feature/TICKET-123-description - •
bugfix/TICKET-123-description - •
username/feature/TICKET-123-description - •
TICKET-123-description
- •
- •Get recent branch names:
- •
Search for ticket IDs:
- •Check the conversation history for any mentioned ticket IDs (patterns like PROJ-123, etc.)
- •If there are staged changes, search them for ticket IDs
- •If no ticket ID found, ask the user for a ticket ID or description
- •
Generate branch name:
- •Follow the repository's detected convention
- •For bug fix branches, add incremental suffix:
- •Check for existing branches matching the base name pattern:
bash
git branch --list '<base-branch-name>*'
- •If no matches exist, append
/1to the branch name - •If matches exist (e.g.,
bugfix/PROJ-123/1,bugfix/PROJ-123/2), use the next number - •Example: if
bugfix/PROJ-123/1andbugfix/PROJ-123/2exist, createbugfix/PROJ-123/3
- •Check for existing branches matching the base name pattern:
- •
Confirm and create:
- •Present the suggested name and ask for confirmation or modification
- •Create the branch:
git checkout -b <branch-name>