Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
184b135886 | ||
|
|
acc0e8666a | ||
|
|
5806aeab27 | ||
|
|
23eb9df482 | ||
|
|
538c9130dc | ||
|
|
a0d3028904 | ||
|
|
59b9e1c419 | ||
|
|
8793248dbe | ||
|
|
f389118515 | ||
|
|
5a7ed03801 | ||
|
|
5f7db6cf5d |
@@ -1,3 +1,24 @@
|
||||
## v1.17.0 - 2026-05-20
|
||||
|
||||
- **feature**: allow merges between environments [[jonathan.nerat](mailto:jonathan.nerat@gmail.com)] (5806aea)
|
||||
|
||||
---
|
||||
|
||||
|
||||
## v1.16.1 - 2026-05-20
|
||||
|
||||
- **bugfix**: arreglo split de branch para armar correctamente el titulo del PR [[jteran](mailto:jteran@renatre.org.ar)] (a0d3028)
|
||||
|
||||
---
|
||||
|
||||
|
||||
## v1.16.0 - 2026-05-20
|
||||
|
||||
- **feature**: agrego soporte para especificar tickets en nombre e rama [[jonathan.nerat](mailto:jonathan.nerat@gmail.com)] (f389118)
|
||||
|
||||
---
|
||||
|
||||
|
||||
## v1.15.0 - 2026-05-17
|
||||
|
||||
- **feature**: include revlist count in version tag when skipping bump [[jonathan.nerat](mailto:jonathan.nerat@gmail.com)] (d275ac0)
|
||||
|
||||
@@ -49,3 +49,5 @@ SUPPORTED_REMOTE_APIS = [
|
||||
]
|
||||
|
||||
REPOSITORY_TOKEN_FILENAME = ".repository-token"
|
||||
|
||||
FLOWCONFIG_FILENAME = ".flowconfig"
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
from git_flow import (
|
||||
BRANCH_TYPES,
|
||||
REPOSITORY_TOKEN_FILENAME,
|
||||
FLOWCONFIG_FILENAME,
|
||||
GitFlowError,
|
||||
)
|
||||
from git_flow.git import FLOWCONFIG_FILE, Git
|
||||
from git_flow.git import Git
|
||||
from git_flow.remote.base import RemoteAPI
|
||||
from git_flow.remote.bitbucket import BitbucketRemoteAPI
|
||||
from git_flow.remote.github import GithubRemoteAPI
|
||||
@@ -16,7 +17,7 @@ TYPE_ERROR = 2
|
||||
TYPE_INFO = 3
|
||||
|
||||
|
||||
flowconfig = Git.get_config(FLOWCONFIG_FILE) if isfile(FLOWCONFIG_FILE) else {}
|
||||
flowconfig = Git.get_config(FLOWCONFIG_FILENAME) if isfile(FLOWCONFIG_FILENAME) else {}
|
||||
|
||||
|
||||
def ensure_initialized():
|
||||
@@ -112,3 +113,15 @@ def get_remote_api(token: str) -> RemoteAPI:
|
||||
return GithubRemoteAPI(repository, token)
|
||||
else:
|
||||
raise GitFlowError("El host del repositorio remoto es inválido")
|
||||
|
||||
def is_valid_ticket(ticket: str) -> bool:
|
||||
"""Check if the specified string is a valid ticket number (ABC-123)"""
|
||||
components = ticket.split("-")
|
||||
|
||||
if len(components) != 2:
|
||||
return False
|
||||
|
||||
ticket_project = components[0]
|
||||
ticket_number = components[1]
|
||||
|
||||
return ticket_project.isalpha() and ticket_project.isupper() and ticket_number.isnumeric()
|
||||
@@ -1,7 +1,7 @@
|
||||
import typer
|
||||
|
||||
from git_flow import GitFlowError
|
||||
from git_flow.git import FLOWCONFIG_FILE, Git
|
||||
from git_flow import FLOWCONFIG_FILENAME, GitFlowError
|
||||
from git_flow.git import Git
|
||||
from git_flow.command.base import *
|
||||
|
||||
app = typer.Typer()
|
||||
@@ -25,8 +25,8 @@ def init():
|
||||
if remote:
|
||||
flowconfig["flow.remote"] = remote
|
||||
|
||||
Git.set_config(flowconfig, FLOWCONFIG_FILE)
|
||||
Git("add", FLOWCONFIG_FILE).exec()
|
||||
Git.set_config(flowconfig, FLOWCONFIG_FILENAME)
|
||||
Git("add", FLOWCONFIG_FILENAME).exec()
|
||||
Git("commit", message="feature: initialize git-flow").exec()
|
||||
|
||||
_ensure_all_flow_branches_exist(branches, remote)
|
||||
@@ -43,7 +43,6 @@ def _ensure_is_repository():
|
||||
|
||||
|
||||
def _ensure_not_already_initialized():
|
||||
flowconfig = get_config()
|
||||
if not flowconfig:
|
||||
return
|
||||
elif flowconfig.get("flow.initialized") == "true":
|
||||
|
||||
@@ -13,6 +13,22 @@ def merge():
|
||||
ensure_initialized()
|
||||
|
||||
branch = ensure_right_branch()
|
||||
environments = flowconfig["flow.branches"].split(",")
|
||||
|
||||
if branch in environments:
|
||||
if branch == environments[-1]:
|
||||
raise GitFlowError("No se puede hacer un merge del último entorno.")
|
||||
|
||||
panel(
|
||||
"Merge de entornos",
|
||||
"""Está por hacer un merge de 2 entornos que puede implicar muchos cambios en el proyecto.""",
|
||||
)
|
||||
|
||||
if not confirm("¿Desea continuar?"):
|
||||
raise GitFlowError("Ejecución abortada")
|
||||
|
||||
target = environments[environments.index(branch) + 1]
|
||||
else:
|
||||
target, _ = get_branch_env_and_type(branch)
|
||||
|
||||
if "flow.remote" in flowconfig:
|
||||
@@ -83,21 +99,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 +118,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("-", " ")
|
||||
]))
|
||||
@@ -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(
|
||||
|
||||
+2
-7
@@ -1,13 +1,8 @@
|
||||
import subprocess
|
||||
|
||||
from git_flow import FLOWCONFIG_FILENAME
|
||||
from git_flow.io import *
|
||||
|
||||
FLOWCONFIG_FILE = ".flowconfig"
|
||||
|
||||
CHANGELOG_FILE = "CHANGELOG.md"
|
||||
|
||||
BUMP_VERSION = "chore: bump version and update CHANGELOG.md [skip ci]"
|
||||
|
||||
|
||||
class Git:
|
||||
class Status:
|
||||
@@ -42,7 +37,7 @@ class Git:
|
||||
|
||||
@staticmethod
|
||||
def flow_config(*args, **kwargs):
|
||||
return Git("config", *args, file=FLOWCONFIG_FILE, **kwargs)
|
||||
return Git("config", *args, file=FLOWCONFIG_FILENAME, **kwargs)
|
||||
|
||||
@staticmethod
|
||||
def get_current_branch():
|
||||
|
||||
Reference in New Issue
Block a user