diff --git a/src/git_flow/command/base.py b/src/git_flow/command/base.py index ae0d3b4..3365b23 100644 --- a/src/git_flow/command/base.py +++ b/src/git_flow/command/base.py @@ -18,7 +18,7 @@ TYPE_INFO = 3 flowconfig = Git.get_config(FLOWCONFIG_FILENAME) if isfile(FLOWCONFIG_FILENAME) else {} - +environments = flowconfig["flow.branches"].split(",") if "flow.branches" in flowconfig else [] def ensure_initialized(): initialized = flowconfig["flow.initialized"] if flowconfig else None @@ -46,7 +46,6 @@ def ensure_right_branch(): def get_branch_env_and_type(branch: str) -> tuple[str, str]: components = branch.split("/") - target_branches = flowconfig["flow.branches"].split(",") if len(components) == 2: if components[0] not in BRANCH_TYPES: @@ -54,13 +53,13 @@ def get_branch_env_and_type(branch: str) -> tuple[str, str]: f"Branch inválida, el tipo '{components[0]}' no es válido." ) - return (target_branches[0], components[0]) + return (environments[0], components[0]) elif len(components) == 4: - target_branches = target_branches[1:] + valid_environments = environments[1:] if ( components[0] != "release" - or components[1] not in target_branches + or components[1] not in valid_environments or components[2] not in BRANCH_TYPES ): raise GitFlowError( diff --git a/src/git_flow/command/branch.py b/src/git_flow/command/branch.py index 7d9f213..ba1e9e3 100644 --- a/src/git_flow/command/branch.py +++ b/src/git_flow/command/branch.py @@ -41,7 +41,6 @@ def branch( ensure_initialized() current_branch = Git.get_current_branch() - environments = flowconfig["flow.branches"].split(",") if current_branch in environments: current_environment = current_branch diff --git a/src/git_flow/command/merge.py b/src/git_flow/command/merge.py index a773267..7a7ba5d 100644 --- a/src/git_flow/command/merge.py +++ b/src/git_flow/command/merge.py @@ -13,7 +13,6 @@ def merge(): ensure_initialized() branch = ensure_right_branch() - environments = flowconfig["flow.branches"].split(",") if branch in environments: if branch == environments[-1]: diff --git a/src/git_flow/command/new.py b/src/git_flow/command/new.py index d381d93..ca9afbc 100644 --- a/src/git_flow/command/new.py +++ b/src/git_flow/command/new.py @@ -13,9 +13,8 @@ def new(): ensure_initialized() branch = ensure_right_branch() - envs = flowconfig["flow.branches"].split(",") - if branch not in envs: + if branch not in environments: warning("La rama actual no corresponde a un entorno configurado.") info("Se creará una nueva rama de trabajo sobre la rama actual.") diff --git a/src/git_flow/command/release.py b/src/git_flow/command/release.py index b20a381..f0402b8 100644 --- a/src/git_flow/command/release.py +++ b/src/git_flow/command/release.py @@ -13,10 +13,9 @@ def release(group: Optional[str] = None): ensure_initialized() branch = ensure_right_branch() - envs = flowconfig["flow.branches"].split(",") env, _ = get_branch_env_and_type(branch) - if env == envs[-1]: + if env == environments[-1]: raise GitFlowError( "No se puede hacer release de una rama en el ultimo entorno." ) @@ -25,7 +24,7 @@ def release(group: Optional[str] = None): ensure_clean_worktree(has_remote) - next_env = envs[envs.index(env) + 1] + next_env = environments[environments.index(env) + 1] next_branch = ( branch.replace(f"/{env}/", f"/{next_env}/") if branch.startswith("release/") diff --git a/src/git_flow/command/tag.py b/src/git_flow/command/tag.py index 9a96526..f7e4b09 100644 --- a/src/git_flow/command/tag.py +++ b/src/git_flow/command/tag.py @@ -20,10 +20,9 @@ def tag(token: Optional[str] = None): """Crea un nuevo tag para el último merge.""" ensure_initialized() - envs = flowconfig["flow.branches"].split(",") target = Git.get_current_branch() - if target not in envs: + if target not in environments: raise GitFlowError("Solo se pueden taggear commits en ramas principales.") branch = Git(