From e793feaa1e2c4828e37bdbb607f6d95059d3b37a Mon Sep 17 00:00:00 2001 From: Jonathan Teran Carballo Date: Mon, 21 Sep 2026 10:44:48 -0300 Subject: [PATCH] bugfix: only return tag on remote tag command, empty if error --- src/git_flow/command/tag.py | 48 ++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/src/git_flow/command/tag.py b/src/git_flow/command/tag.py index 2c944f3..8a530fe 100644 --- a/src/git_flow/command/tag.py +++ b/src/git_flow/command/tag.py @@ -32,7 +32,15 @@ def tag(token: Optional[str] = None): if ci and not token: raise GitFlowError("No hay token disponible") - merge_commit = get_last_merge_commit() + merge_commit = Git( + "log", first_parent=True, merges=True, max_count=1, format="%H" + ).firstline() + + if not merge_commit: + if not ci: + raise GitFlowError("No hay merges a taggear.") + return + # Con varios entornos cada uno versiona por separado (v1.0.0-prod), con uno solo no hace falta suffix = f"-{target}" if len(base.environments) > 1 else "" @@ -55,23 +63,25 @@ def tag(token: Optional[str] = None): ) if not next_tag: - base.io_info( - "Los cambios realizados no implican un salto de versión, se mantiene la anterior." - ) + if not ci: + base.io_info( + "Los cambios realizados no implican un salto de versión, se mantiene la anterior." + ) return changelog = Changelog() changelog.update(next_tag, commits) - Git("add", Changelog.FILENAME).exec(print="Agregando nuevo CHANGELOG.md") - Git("commit", message=Changelog.COMMIT_MESSAGE).exec(print="Creando commit") + Git("add", Changelog.FILENAME).exec(print=None if ci else "Agregando nuevo CHANGELOG.md") + Git("commit", message=Changelog.COMMIT_MESSAGE).exec(print=None if ci else "Creando commit") tag_commit = Git("show", "HEAD", patch=False, format="%h").firstline() if ci: - Git("push").exec(print="Subiendo commit al remoto para taggearlo") - base.io_success(base.get_remote_api(token).create_tag(next_tag, tag_commit)) - - Git("tag", next_tag, tag_commit).exec(print="Creando tag localmente") + Git("push").exec() + base.get_remote_api(token).create_tag(next_tag, tag_commit) + print(next_tag) + else: + Git("tag", next_tag, tag_commit).exec(print="Creando tag localmente") def get_token_and_ci(token: Optional[str]): @@ -81,24 +91,6 @@ def get_token_and_ci(token: Optional[str]): return (base.ensure_repository_token(), False) -def get_last_merge_commit(): - commit = Git( - "log", first_parent=True, merges=True, max_count=1, format="%H" - ).firstline() - - if not commit: - raise GitFlowError("No hay merges a taggear.") - - return commit - - -def check_not_tagged(commit: str): - tag = Git("describe", commit, tags=True, exact_match=True).firstline(check=False) - - if tag: - raise GitFlowError("El commit a taggear ya tiene tag: " + tag) - - def get_next_tag_from_commits( commits: list[str], suffix: str, current_tag: str | None ) -> str | None: