From 499babcaec7009fd606336ed611fbfc013bd624f Mon Sep 17 00:00:00 2001 From: Jonathan Teran Carballo Date: Sun, 14 Dec 2025 21:40:54 -0300 Subject: [PATCH 1/5] bugfix: elimino : extra de comando new --- src/git_flow/command/new.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/git_flow/command/new.py b/src/git_flow/command/new.py index 2f142b5..4ed6233 100644 --- a/src/git_flow/command/new.py +++ b/src/git_flow/command/new.py @@ -44,7 +44,7 @@ class NewCommand(Command): persistent=True, ) - ticket = self.prompt("[Opcional] Ingrese el ID del ticket (por ejemplo: ABC-123 o #123):") + 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(" ")) From 74c333aa1a783a8535dda8265a9a4af97015c15b Mon Sep 17 00:00:00 2001 From: Jonathan Teran Carballo Date: Sun, 14 Dec 2025 21:48:44 -0300 Subject: [PATCH 2/5] refactor: cambio opcion para listar ramas trash --- src/git_flow/command/branch.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/git_flow/command/branch.py b/src/git_flow/command/branch.py index c5f72c1..f987bdf 100644 --- a/src/git_flow/command/branch.py +++ b/src/git_flow/command/branch.py @@ -18,7 +18,13 @@ class BranchCommand(Command): parser.add_argument( "environment", 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="Listar ramas en la 'papelera de reciclaje' (ramas que empiezan con 'trash/')" ) return parser @@ -29,14 +35,14 @@ class BranchCommand(Command): self.current_branch = Git.get_current_branch() self.environments = self.flowconfig["flow.branches"].split(",") + if args.trash: + self.show_trash_branches() if args.environment is None: self.show_envs() self.show_all_branches() elif args.environment in self.environments: self.show_envs() self.show_env_branches(args.environment) - elif args.environment == "trash": - self.show_trash_branches() else: raise GitFlowError(f"'{args.environment}' no es un entorno válido.") From 774cf9ade61a97c60dd2d3fa60dfafcb65e441dc Mon Sep 17 00:00:00 2001 From: Jonathan Teran Carballo Date: Sun, 14 Dec 2025 21:56:18 -0300 Subject: [PATCH 3/5] feature: agrego opcion para listar ramas wip --- src/git_flow/__init__.py | 3 +++ src/git_flow/command/branch.py | 28 ++++++++++++++++++---------- src/git_flow/command/commit.py | 10 +++++----- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/src/git_flow/__init__.py b/src/git_flow/__init__.py index 454bea0..049ad89 100644 --- a/src/git_flow/__init__.py +++ b/src/git_flow/__init__.py @@ -21,6 +21,9 @@ COMMIT_TYPES = [ "wip", ] +WIP_BRANCH_PREFIX = "wip/" +TRASH_BRANCH_PREFIX = "trash/" + # Commits con estos valores incrementan el componente correspondiente SEMVER_MAJOR = 3 SEMVER_MINOR = 2 diff --git a/src/git_flow/command/branch.py b/src/git_flow/command/branch.py index f987bdf..e02a298 100644 --- a/src/git_flow/command/branch.py +++ b/src/git_flow/command/branch.py @@ -1,5 +1,5 @@ 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.git import Git @@ -24,7 +24,13 @@ class BranchCommand(Command): parser.add_argument( "--trash", action="store_true", - help="Listar ramas en la 'papelera de reciclaje' (ramas que empiezan con 'trash/')" + 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}')" ) return parser @@ -36,8 +42,10 @@ class BranchCommand(Command): self.environments = self.flowconfig["flow.branches"].split(",") if args.trash: - self.show_trash_branches() - if args.environment is None: + self.show_branches(TRASH_BRANCH_PREFIX) + elif args.wip: + self.show_branches(WIP_BRANCH_PREFIX) + elif args.environment is None: self.show_envs() self.show_all_branches() elif args.environment in self.environments: @@ -46,8 +54,8 @@ class BranchCommand(Command): else: raise GitFlowError(f"'{args.environment}' no es un entorno válido.") - def show_trash_branches(self): - branches = self.get_trash_branches() + def show_branches(self, prefix: str): + branches = self.get_branches(prefix) if not branches: print("No hay ramas a mostrar.") @@ -57,14 +65,14 @@ class BranchCommand(Command): prefix = (COLOR_RED + "*") if branch == self.current_branch else " " print(prefix + " " + branch + COLOR_RESET) - def get_trash_branches(self): - return Git("for-each-ref", "refs/heads/trash/", format=BRANCH_FORMAT).lines() + def get_branches(self, prefix: str): + return Git("for-each-ref", "refs/heads/" + prefix, format=BRANCH_FORMAT).lines() def show_all_branches(self): for environment in self.environments: 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: print() @@ -81,7 +89,7 @@ class BranchCommand(Command): is_first_env = environment == self.environments[0] pattern = "refs/heads/" if is_first_env else "refs/heads/release/" + environment + "/" 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() print(COLOR_WHITE_BOLD + (environment if show_env else "Ramas") + COLOR_RESET) diff --git a/src/git_flow/command/commit.py b/src/git_flow/command/commit.py index 2966fe3..73c1fdd 100644 --- a/src/git_flow/command/commit.py +++ b/src/git_flow/command/commit.py @@ -1,6 +1,6 @@ from argparse import Namespace 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.git import Git @@ -31,8 +31,8 @@ class CommitCommand(Command): ) message = commit_type + ": " + commit_message - if branch.startswith("wip/"): - original_branch = branch.removeprefix("wip/") + if branch.startswith(WIP_BRANCH_PREFIX): + original_branch = branch.removeprefix(WIP_BRANCH_PREFIX) Git("commit", m=message).exec(print="Creando commit en rama WIP") if commit_type != "wip": @@ -40,10 +40,10 @@ class CommitCommand(Command): Git("switch", original_branch).exec(print="Volviendo a rama original") 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("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: 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") From 104b3214d4d360f14177e12da46bd04226d0db8c Mon Sep 17 00:00:00 2001 From: Jonathan Teran Carballo Date: Sun, 14 Dec 2025 22:00:14 -0300 Subject: [PATCH 4/5] feature: listar ramas de todos los entornos con flag --all, y del entorno actual por defecto --- src/git_flow/command/branch.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/git_flow/command/branch.py b/src/git_flow/command/branch.py index e02a298..b6c8d06 100644 --- a/src/git_flow/command/branch.py +++ b/src/git_flow/command/branch.py @@ -33,6 +33,12 @@ class BranchCommand(Command): 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 def run(self, args: Namespace = Namespace()): @@ -45,9 +51,12 @@ class BranchCommand(Command): self.show_branches(TRASH_BRANCH_PREFIX) elif args.wip: self.show_branches(WIP_BRANCH_PREFIX) - elif args.environment is None: + elif args.all: self.show_envs() self.show_all_branches() + elif args.environment is None: + self.show_envs() + self.show_env_branches(self.current_branch) elif args.environment in self.environments: self.show_envs() self.show_env_branches(args.environment) From 5d33b29abdbcc0b7c3328ae0e4271baf9672b23a Mon Sep 17 00:00:00 2001 From: Jonathan Teran Carballo Date: Sun, 14 Dec 2025 22:10:00 -0300 Subject: [PATCH 5/5] bugfix: uso env actual en vez de rama actual para listar ramas --- src/git_flow/command/branch.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/git_flow/command/branch.py b/src/git_flow/command/branch.py index b6c8d06..73d1818 100644 --- a/src/git_flow/command/branch.py +++ b/src/git_flow/command/branch.py @@ -46,6 +46,7 @@ class BranchCommand(Command): self.current_branch = Git.get_current_branch() self.environments = self.flowconfig["flow.branches"].split(",") + (current_environment, _) = self.get_branch_env_and_type(self.current_branch) if args.trash: self.show_branches(TRASH_BRANCH_PREFIX) @@ -56,7 +57,7 @@ class BranchCommand(Command): self.show_all_branches() elif args.environment is None: self.show_envs() - self.show_env_branches(self.current_branch) + self.show_env_branches(current_environment) elif args.environment in self.environments: self.show_envs() self.show_env_branches(args.environment)