feature: agrego soporte para especificar tickets en nombre e rama
This commit is contained in:
@@ -83,21 +83,12 @@ def check_merge_conflicts(target: str):
|
||||
def create_pull_request(token: str, branch: str, target: str):
|
||||
changelog = Changelog()
|
||||
commits = Git("log", target + "..", format="%s").lines()
|
||||
title = commits[0] if len(commits) == 1 else _get_pr_title_from_branch(branch)
|
||||
|
||||
if len(commits) == 1:
|
||||
title = commits[0]
|
||||
else:
|
||||
title = branch.replace("/", ": ").replace("-", " ")
|
||||
panel("Título del PR", title)
|
||||
|
||||
if title.startswith("release: "):
|
||||
title = title[title.index(" ", title.index(" ") + 1) + 1 :]
|
||||
|
||||
info("Título del PR por defecto: " + title)
|
||||
|
||||
opt_title = prompt("[Opcional] Ingrese otro titulo para el PR")
|
||||
|
||||
if opt_title:
|
||||
title = opt_title
|
||||
if confirm("¿Desea cambiar el título del PR?", False):
|
||||
title = prompt("Título del PR")
|
||||
|
||||
message = get_remote_api(token).create_pull_request(
|
||||
branch,
|
||||
@@ -111,3 +102,26 @@ def create_pull_request(token: str, branch: str, target: str):
|
||||
if confirm("¿Desea cambiar a la rama objetivo y bajar los cambios?"):
|
||||
Git("switch", target).exec(print="Cambiando a rama objetivo")
|
||||
Git("pull").exec(print="Obteniendo cambios")
|
||||
|
||||
def _get_pr_title_from_branch(branch: str) -> str:
|
||||
components = branch.split("-") # <type>/<desc> or release/<env>/<type>/<desc>
|
||||
branch_type = components[-2]
|
||||
branch_desc = components[-1]
|
||||
|
||||
# detect if branch description has ticket as prefix: <desc> = ABC-123-my-branch-name
|
||||
branch_ticket = None
|
||||
first_dash = branch_desc.find("-")
|
||||
second_dash = branch_desc.find("-", first_dash + 1)
|
||||
|
||||
if first_dash >= 0 and second_dash >= 0:
|
||||
maybe_ticket = branch_desc[:second_dash]
|
||||
if is_valid_ticket(maybe_ticket):
|
||||
branch_ticket = maybe_ticket
|
||||
branch_desc = branch_desc[:second_dash+1]
|
||||
|
||||
return " ".join(filter(None, [
|
||||
f"[Pasaje a {components[1]}]" if len(components) == 4 else None,
|
||||
branch_type + ":",
|
||||
branch_ticket,
|
||||
branch_desc.replace("-", " ")
|
||||
]))
|
||||
Reference in New Issue
Block a user