feature: agrego soporte para especificar tickets en nombre e rama

This commit is contained in:
jt
2026-05-19 23:29:22 -03:00
parent 5a7ed03801
commit f389118515
3 changed files with 54 additions and 16 deletions
+15 -3
View File
@@ -2,6 +2,7 @@ import typer
from git_flow import BRANCH_TYPES
from git_flow.command.base import *
from git_flow.git import Git
from typing import Optional
app = typer.Typer()
@@ -21,7 +22,8 @@ def new():
info("Debe seleccionar el tipo de cambio a realizar.")
branch_type = choice("Tipos de cambio", BRANCH_TYPES)
new_branch = _get_unique_branch_name(branch_type)
ticket = _get_optional_ticket()
new_branch = _get_unique_branch_name(branch_type, ticket)
if "flow.remote" in flowconfig and Git.get_tracking_branch(branch):
Git("pull").exec(print="Actualizando rama actual")
@@ -29,8 +31,18 @@ def new():
if confirm(f"¿Crear rama '{new_branch}' sobre la rama actual?"):
Git("switch", new_branch, create=True).exec(print="Creando nueva rama")
def _get_optional_ticket() -> Optional[str]:
ticket = prompt("[Opcional] Ticket que respalda el cambio (en formato ABC-123)")
def _get_unique_branch_name(branch_type: str) -> str:
if not ticket:
return None
if not is_valid_ticket(ticket):
warning("Formato de ticket inválido, ignorando.")
return None
return ticket
def _get_unique_branch_name(branch_type: str, ticket: Optional[str]) -> str:
info(f"Ingrese las palabras clave que describan el cambio de tipo '{branch_type}'.")
branch = None
branches = Git.get_branches()
@@ -42,7 +54,7 @@ def _get_unique_branch_name(branch_type: str) -> str:
)
keywords = filter(lambda k: len(k) > 0, keywords.split(" "))
branch = branch_type + "/" + "-".join(keywords)
branch = branch_type + "/" + (ticket + "-" if ticket else "") + "-".join(keywords)
if branch in branches:
error(