From aacc5b90e225b6956bbdafc0d834f822b065c4dc Mon Sep 17 00:00:00 2001 From: Jonathan Teran Carballo Date: Sat, 26 Sep 2026 21:15:20 -0300 Subject: [PATCH] bugfix: prevent commits on environments --- README.md | 2 +- src/git_flow/command/commit.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 58d5c3a..a133a25 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ más información): - `init`: Inicializa el repositorio para utilizar git-flow (ramas principales y remoto). - `new`: Crea una nueva rama siguiendo CB. -- `commit`: Crea un commit siguiendo CC. +- `commit`: Crea un commit siguiendo CC. No permite commitear directamente sobre un entorno. - `merge`: Mergea la rama actual a uno de los entornos. - `tag`: Crea un tag sobre el ultimo merge siguiendo SemVer (ver [Tag](#tag)). - `release`: Prepara la rama actual para pasarse al siguiente entorno configurado. diff --git a/src/git_flow/command/commit.py b/src/git_flow/command/commit.py index a7834d6..07c3559 100644 --- a/src/git_flow/command/commit.py +++ b/src/git_flow/command/commit.py @@ -15,6 +15,15 @@ def commit(): base.ensure_initialized() branch = base.ensure_right_branch() + # Una rama WIP termina squasheando en su rama original, que tampoco puede ser un entorno + target_branch = branch.removeprefix(WIP_BRANCH_PREFIX) + + if target_branch in base.environments: + raise GitFlowError( + f"No se puede commitear directamente sobre el entorno '{target_branch}'. " + "Debe crear una rama de trabajo con el comando `new`." + ) + if not _has_files_staged(): base.io_warning("No hay cambios en el indice para commitear.") if base.io_confirm("¿Desea agregar la carpeta actual?"):