Compare commits
@@ -1,3 +1,59 @@
|
|||||||
|
## v1.9.0 - 2025-12-15
|
||||||
|
|
||||||
|
- **bugfix**: uso env actual en vez de rama actual para listar ramas [[jteran](mailto:jteran@renatre.org.ar)] (5d33b29)
|
||||||
|
- **feature**: listar ramas de todos los entornos con flag --all, y del entorno actual por defecto [[jteran](mailto:jteran@renatre.org.ar)] (104b321)
|
||||||
|
- **feature**: agrego opcion para listar ramas wip [[jteran](mailto:jteran@renatre.org.ar)] (774cf9a)
|
||||||
|
- **refactor**: cambio opcion para listar ramas trash [[jteran](mailto:jteran@renatre.org.ar)] (74c333a)
|
||||||
|
- **bugfix**: elimino : extra de comando new [[jteran](mailto:jteran@renatre.org.ar)] (499babc)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
## v1.8.0 - 2025-12-15
|
||||||
|
|
||||||
|
- **feature**: agrego opcion para incluir ticket en nombre de rama [[jteran](mailto:jteran@renatre.org.ar)] (01e938e)
|
||||||
|
- **feature**: mostrar warning si la rama actual no es un entorno configurado [[jteran](mailto:jteran@renatre.org.ar)] (97b4a56)
|
||||||
|
- **feature**: hacer pull en rama actual antes de crear nueva rama [[jteran](mailto:jteran@renatre.org.ar)] (24be501)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
## v1.7.5 - 2025-12-14
|
||||||
|
|
||||||
|
- **bugfix**: verificar si la rama grupo trackea una rama remota antes de hacer pull [[jteran](mailto:jteran@renatre.org.ar)] (0d95a97)
|
||||||
|
- **bugfix**: capturo interrupion por teclado para no mostrar stack trace [[jteran](mailto:jteran@renatre.org.ar)] (0af5102)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
## v1.7.4 - 2025-12-14
|
||||||
|
|
||||||
|
- **bugfix**: generación de PR de ramas release [[jteran](mailto:jteran@renatre.org.ar)] (b24b22a)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
## v1.7.3 - 2025-12-14
|
||||||
|
|
||||||
|
- **bugfix**: listado de ramas para elegir grupo release no devolvia resultados [[jteran](mailto:jteran@renatre.org.ar)] (5600e5e)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
## v1.7.2 - 2025-12-11
|
||||||
|
|
||||||
|
- **bugfix**: al hacer un release, cambio a la rama grupo si esta disponible [[jteran](mailto:jteran@renatre.org.ar)] (44b8efd)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
## v1.7.1 - 2025-12-11
|
||||||
|
|
||||||
|
- **bugfix**: cambio la forma en la que se obtiene el first fork point entre 2 ramas [[jteran](mailto:jteran@renatre.org.ar)] (7b4fb34)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
## v1.7.0 - 2025-12-11
|
## v1.7.0 - 2025-12-11
|
||||||
|
|
||||||
- **feature**: muestro el listado de commits a pasar al siguiente entorno en release [[jteran](mailto:jteran@renatre.org.ar)] (2e65cb7)
|
- **feature**: muestro el listado de commits a pasar al siguiente entorno en release [[jteran](mailto:jteran@renatre.org.ar)] (2e65cb7)
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ COMMIT_TYPES = [
|
|||||||
"wip",
|
"wip",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
WIP_BRANCH_PREFIX = "wip/"
|
||||||
|
TRASH_BRANCH_PREFIX = "trash/"
|
||||||
|
|
||||||
# Commits con estos valores incrementan el componente correspondiente
|
# Commits con estos valores incrementan el componente correspondiente
|
||||||
SEMVER_MAJOR = 3
|
SEMVER_MAJOR = 3
|
||||||
SEMVER_MINOR = 2
|
SEMVER_MINOR = 2
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
from argparse import ArgumentParser, Namespace
|
from argparse import ArgumentParser, Namespace
|
||||||
from git_flow import COLOR_WHITE_BOLD, COLOR_GREEN, COLOR_RED, COLOR_RESET, GitFlowError
|
from git_flow import COLOR_WHITE_BOLD, COLOR_GREEN, COLOR_RED, COLOR_RESET, TRASH_BRANCH_PREFIX, WIP_BRANCH_PREFIX, GitFlowError
|
||||||
from git_flow.command.base import Command
|
from git_flow.command.base import Command
|
||||||
from git_flow.git import Git
|
from git_flow.git import Git
|
||||||
|
|
||||||
@@ -18,7 +18,25 @@ class BranchCommand(Command):
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"environment",
|
"environment",
|
||||||
nargs="?",
|
nargs="?",
|
||||||
help="Entorno de las ramas a listar. Puede ser vacio para listar ramas de todos los entornos, un entorno válido, o 'trash' para listar las ramas eliminadas.",
|
help="Entorno de las ramas a listar. Por defecto, es el entorno actual.",
|
||||||
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
"--trash",
|
||||||
|
action="store_true",
|
||||||
|
help=f"Listar ramas en la 'papelera de reciclaje' (ramas que empiezan con '{TRASH_BRANCH_PREFIX}')"
|
||||||
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
"--wip",
|
||||||
|
action="store_true",
|
||||||
|
help=f"Listar ramas 'en progreso' (ramas que empiezan con '{WIP_BRANCH_PREFIX}')"
|
||||||
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
"--all",
|
||||||
|
action="store_true",
|
||||||
|
help=f"Listar ramas de todos los entornos"
|
||||||
)
|
)
|
||||||
|
|
||||||
return parser
|
return parser
|
||||||
@@ -28,20 +46,26 @@ class BranchCommand(Command):
|
|||||||
|
|
||||||
self.current_branch = Git.get_current_branch()
|
self.current_branch = Git.get_current_branch()
|
||||||
self.environments = self.flowconfig["flow.branches"].split(",")
|
self.environments = self.flowconfig["flow.branches"].split(",")
|
||||||
|
(current_environment, _) = self.get_branch_env_and_type(self.current_branch)
|
||||||
|
|
||||||
if args.environment is None:
|
if args.trash:
|
||||||
|
self.show_branches(TRASH_BRANCH_PREFIX)
|
||||||
|
elif args.wip:
|
||||||
|
self.show_branches(WIP_BRANCH_PREFIX)
|
||||||
|
elif args.all:
|
||||||
self.show_envs()
|
self.show_envs()
|
||||||
self.show_all_branches()
|
self.show_all_branches()
|
||||||
|
elif args.environment is None:
|
||||||
|
self.show_envs()
|
||||||
|
self.show_env_branches(current_environment)
|
||||||
elif args.environment in self.environments:
|
elif args.environment in self.environments:
|
||||||
self.show_envs()
|
self.show_envs()
|
||||||
self.show_env_branches(args.environment)
|
self.show_env_branches(args.environment)
|
||||||
elif args.environment == "trash":
|
|
||||||
self.show_trash_branches()
|
|
||||||
else:
|
else:
|
||||||
raise GitFlowError(f"'{args.environment}' no es un entorno válido.")
|
raise GitFlowError(f"'{args.environment}' no es un entorno válido.")
|
||||||
|
|
||||||
def show_trash_branches(self):
|
def show_branches(self, prefix: str):
|
||||||
branches = self.get_trash_branches()
|
branches = self.get_branches(prefix)
|
||||||
|
|
||||||
if not branches:
|
if not branches:
|
||||||
print("No hay ramas a mostrar.")
|
print("No hay ramas a mostrar.")
|
||||||
@@ -51,14 +75,14 @@ class BranchCommand(Command):
|
|||||||
prefix = (COLOR_RED + "*") if branch == self.current_branch else " "
|
prefix = (COLOR_RED + "*") if branch == self.current_branch else " "
|
||||||
print(prefix + " " + branch + COLOR_RESET)
|
print(prefix + " " + branch + COLOR_RESET)
|
||||||
|
|
||||||
def get_trash_branches(self):
|
def get_branches(self, prefix: str):
|
||||||
return Git("for-each-ref", "refs/heads/trash/", format=BRANCH_FORMAT).lines()
|
return Git("for-each-ref", "refs/heads/" + prefix, format=BRANCH_FORMAT).lines()
|
||||||
|
|
||||||
def show_all_branches(self):
|
def show_all_branches(self):
|
||||||
for environment in self.environments:
|
for environment in self.environments:
|
||||||
self.show_env_branches(environment, len(self.environments) > 1)
|
self.show_env_branches(environment, len(self.environments) > 1)
|
||||||
|
|
||||||
trash = len(self.get_trash_branches())
|
trash = len(self.get_branches(TRASH_BRANCH_PREFIX))
|
||||||
|
|
||||||
if trash:
|
if trash:
|
||||||
print()
|
print()
|
||||||
@@ -75,7 +99,7 @@ class BranchCommand(Command):
|
|||||||
is_first_env = environment == self.environments[0]
|
is_first_env = environment == self.environments[0]
|
||||||
pattern = "refs/heads/" if is_first_env else "refs/heads/release/" + environment + "/"
|
pattern = "refs/heads/" if is_first_env else "refs/heads/release/" + environment + "/"
|
||||||
pattern += "*/*"
|
pattern += "*/*"
|
||||||
exclude = ["refs/heads/trash/", "refs/heads/release/"] if is_first_env else []
|
exclude = ["refs/heads/" + TRASH_BRANCH_PREFIX, "refs/heads/release/"] if is_first_env else []
|
||||||
branches = Git("for-each-ref", pattern, exclude=exclude, format=BRANCH_FORMAT).lines()
|
branches = Git("for-each-ref", pattern, exclude=exclude, format=BRANCH_FORMAT).lines()
|
||||||
|
|
||||||
print(COLOR_WHITE_BOLD + (environment if show_env else "Ramas") + COLOR_RESET)
|
print(COLOR_WHITE_BOLD + (environment if show_env else "Ramas") + COLOR_RESET)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
from argparse import Namespace
|
from argparse import Namespace
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from git_flow import COMMIT_TYPES, GitFlowError
|
from git_flow import COMMIT_TYPES, TRASH_BRANCH_PREFIX, WIP_BRANCH_PREFIX, GitFlowError
|
||||||
from git_flow.command.base import Command
|
from git_flow.command.base import Command
|
||||||
from git_flow.git import Git
|
from git_flow.git import Git
|
||||||
|
|
||||||
@@ -31,8 +31,8 @@ class CommitCommand(Command):
|
|||||||
)
|
)
|
||||||
message = commit_type + ": " + commit_message
|
message = commit_type + ": " + commit_message
|
||||||
|
|
||||||
if branch.startswith("wip/"):
|
if branch.startswith(WIP_BRANCH_PREFIX):
|
||||||
original_branch = branch.removeprefix("wip/")
|
original_branch = branch.removeprefix(WIP_BRANCH_PREFIX)
|
||||||
Git("commit", m=message).exec(print="Creando commit en rama WIP")
|
Git("commit", m=message).exec(print="Creando commit en rama WIP")
|
||||||
|
|
||||||
if commit_type != "wip":
|
if commit_type != "wip":
|
||||||
@@ -40,10 +40,10 @@ class CommitCommand(Command):
|
|||||||
Git("switch", original_branch).exec(print="Volviendo a rama original")
|
Git("switch", original_branch).exec(print="Volviendo a rama original")
|
||||||
Git("merge", branch, squash=True).exec(print="Squasheando commits WIP en uno solo")
|
Git("merge", branch, squash=True).exec(print="Squasheando commits WIP en uno solo")
|
||||||
Git("commit", m=message).exec(print="Creando commit final de rama WIP")
|
Git("commit", m=message).exec(print="Creando commit final de rama WIP")
|
||||||
Git("branch", branch, "trash/" + branch + "/" + suffix, move=True).exec(print="Backup de rama WIP")
|
Git("branch", branch, TRASH_BRANCH_PREFIX + branch + "/" + suffix, move=True).exec(print="Backup de rama WIP")
|
||||||
else:
|
else:
|
||||||
if commit_type == "wip":
|
if commit_type == "wip":
|
||||||
Git("switch", "wip/" + branch, create=True).exec(print="Creando nueva rama WIP")
|
Git("switch", WIP_BRANCH_PREFIX + branch, create=True).exec(print="Creando nueva rama WIP")
|
||||||
|
|
||||||
Git("commit", m=message).exec(print="Creando commit")
|
Git("commit", m=message).exec(print="Creando commit")
|
||||||
|
|
||||||
|
|||||||
@@ -80,6 +80,10 @@ class MergeCommand(Command):
|
|||||||
|
|
||||||
def create_pull_request(self, token: str, branch: str, target: str):
|
def create_pull_request(self, token: str, branch: str, target: str):
|
||||||
changelog = Changelog()
|
changelog = Changelog()
|
||||||
|
title = branch.replace("/", ": ").replace("-", " ")
|
||||||
|
|
||||||
|
if title.startswith("release: "):
|
||||||
|
title = title[title.index(' ', title.index(' ') + 1) + 1:]
|
||||||
|
|
||||||
message = self.get_remote_api(token).create_pull_request(
|
message = self.get_remote_api(token).create_pull_request(
|
||||||
branch,
|
branch,
|
||||||
|
|||||||
@@ -13,7 +13,11 @@ class NewCommand(Command):
|
|||||||
|
|
||||||
def run(self, args: Namespace = Namespace()):
|
def run(self, args: Namespace = Namespace()):
|
||||||
self.ensure_initialized()
|
self.ensure_initialized()
|
||||||
self.ensure_right_branch()
|
branch = self.ensure_right_branch()
|
||||||
|
envs = self.flowconfig["flow.branches"].split(",")
|
||||||
|
|
||||||
|
if branch not in envs:
|
||||||
|
self.warning("La rama actual no corresponde a un entorno configurado.")
|
||||||
|
|
||||||
self.info("Se creará una nueva rama de trabajo sobre la rama actual.")
|
self.info("Se creará una nueva rama de trabajo sobre la rama actual.")
|
||||||
self.info("Debe seleccionar el tipo de cambio a realizar.")
|
self.info("Debe seleccionar el tipo de cambio a realizar.")
|
||||||
@@ -21,6 +25,9 @@ class NewCommand(Command):
|
|||||||
branch_type = self.choice("Tipos de cambio", BRANCH_TYPES)
|
branch_type = self.choice("Tipos de cambio", BRANCH_TYPES)
|
||||||
new_branch = self._get_unique_branch_name(branch_type)
|
new_branch = self._get_unique_branch_name(branch_type)
|
||||||
|
|
||||||
|
if "flow.remote" in self.flowconfig and Git.get_tracking_branch(branch):
|
||||||
|
Git("pull").exec(print="Actualizando rama actual")
|
||||||
|
|
||||||
if self.confirm(f"¿Crear rama '{new_branch}' sobre la rama actual?"):
|
if self.confirm(f"¿Crear rama '{new_branch}' sobre la rama actual?"):
|
||||||
Git("switch", new_branch, create=True).exec(print="Creando nueva rama")
|
Git("switch", new_branch, create=True).exec(print="Creando nueva rama")
|
||||||
|
|
||||||
@@ -37,6 +44,9 @@ class NewCommand(Command):
|
|||||||
persistent=True,
|
persistent=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
ticket = self.prompt("[Opcional] Ingrese el ID del ticket (por ejemplo ABC-123 o #123)")
|
||||||
|
ticket = ticket[1:] if ticket.startswith("#") else ticket
|
||||||
|
keywords = ticket + ' ' + keywords
|
||||||
keywords = filter(lambda k: len(k) > 0, keywords.split(" "))
|
keywords = filter(lambda k: len(k) > 0, keywords.split(" "))
|
||||||
branch = branch_type + "/" + "-".join(keywords)
|
branch = branch_type + "/" + "-".join(keywords)
|
||||||
|
|
||||||
|
|||||||
@@ -56,12 +56,13 @@ class ReleaseCommand(Command):
|
|||||||
|
|
||||||
group = args.group
|
group = args.group
|
||||||
|
|
||||||
if not group and self.confirm("¿Desea agrupar este release con otra rama?", False):
|
if not group:
|
||||||
group = self.choice("Grupo release: ", Git.get_branches("release/" + next_env + "/"))
|
if self.confirm("¿Desea agrupar este release con otra rama?", False):
|
||||||
else:
|
group = self.choice("Grupo release: ", Git.get_branches("release/" + next_env + "/"))
|
||||||
group = next_env
|
else:
|
||||||
|
group = next_env
|
||||||
|
|
||||||
if has_remote:
|
if has_remote and Git.get_tracking_branch(group):
|
||||||
Git("switch", group).exec(print="Cambiando a la rama objetivo")
|
Git("switch", group).exec(print="Cambiando a la rama objetivo")
|
||||||
Git("pull").exec(print="Sincronizando cambios la rama objetivo")
|
Git("pull").exec(print="Sincronizando cambios la rama objetivo")
|
||||||
Git("switch", "-").exec(print="Volviendo a la rama original")
|
Git("switch", "-").exec(print="Volviendo a la rama original")
|
||||||
|
|||||||
+13
-14
@@ -1,5 +1,6 @@
|
|||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
from git_flow import GitFlowError
|
||||||
from git_flow.io import *
|
from git_flow.io import *
|
||||||
|
|
||||||
|
|
||||||
@@ -63,32 +64,30 @@ class Git:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_first_fork_point(branch: str, env: str):
|
def get_first_fork_point(branch: str, env: str):
|
||||||
boundary_commits = list(
|
# Lista de commits alcanzables por el entorno (por ejemplo, dev),
|
||||||
filter(
|
env_commits = Git("rev-list", env + "..." + branch, first_parent=True).lines()
|
||||||
lambda c: c.startswith("-"), # boundary commits
|
|
||||||
Git(
|
|
||||||
"rev-list", env + "..." + branch, topo_order=True, boundary=True
|
|
||||||
).lines(),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
if not boundary_commits:
|
if not env_commits:
|
||||||
raise RuntimeError("No se encontro un commit base para realizar el rebase.")
|
raise RuntimeError("No se encontro un commit base para realizar el rebase.")
|
||||||
|
|
||||||
return boundary_commits[-1].removeprefix("-")
|
return Git("show", env_commits[-1] + "^", patch=False, format="%h").firstline()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _get_references(kind: str):
|
def _get_references(kind: str):
|
||||||
prefix = "refs/" + kind
|
prefix = "refs/" + kind
|
||||||
return list(map(
|
return Git("for-each-ref", prefix + "**", format="%(refname:short)").lines()
|
||||||
lambda r: r.removeprefix(prefix),
|
|
||||||
Git("for-each-ref", prefix + "*", format="%(refname)").lines(),
|
|
||||||
))
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def is_repository() -> bool:
|
def is_repository() -> bool:
|
||||||
return Git("rev-parse", is_inside_work_tree=True).code() == 0
|
return Git("rev-parse", is_inside_work_tree=True).code() == 0
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_tracking_branch(branch: str) -> str | None:
|
||||||
|
try:
|
||||||
|
return Git("rev-parse", branch + "@{upstream}", abbrev_ref=True).firstline()
|
||||||
|
except subprocess.CalledProcessError:
|
||||||
|
return None
|
||||||
|
|
||||||
def __init__(self, subcommand: str, *args: str, **kwargs: str | int | bool | list[str] | None) -> None:
|
def __init__(self, subcommand: str, *args: str, **kwargs: str | int | bool | list[str] | None) -> None:
|
||||||
self.command = ["git", subcommand]
|
self.command = ["git", subcommand]
|
||||||
|
|
||||||
|
|||||||
@@ -79,6 +79,9 @@ def main():
|
|||||||
command.error(str(e))
|
command.error(str(e))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
command.error("Ocurrió un error inesperado: " + str(e))
|
command.error("Ocurrió un error inesperado: " + str(e))
|
||||||
|
except KeyboardInterrupt as e:
|
||||||
|
print()
|
||||||
|
command.error("Ejecución abortada")
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user