bugfix: only return tag on remote tag command, empty if error

This commit is contained in:
Jonathan Teran Carballo
2026-09-21 10:44:48 -03:00
parent d03cf964e1
commit e793feaa1e
+16 -24
View File
@@ -32,7 +32,15 @@ def tag(token: Optional[str] = None):
if ci and not token: if ci and not token:
raise GitFlowError("No hay token disponible") 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 # 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 "" suffix = f"-{target}" if len(base.environments) > 1 else ""
@@ -55,6 +63,7 @@ def tag(token: Optional[str] = None):
) )
if not next_tag: if not next_tag:
if not ci:
base.io_info( base.io_info(
"Los cambios realizados no implican un salto de versión, se mantiene la anterior." "Los cambios realizados no implican un salto de versión, se mantiene la anterior."
) )
@@ -63,14 +72,15 @@ def tag(token: Optional[str] = None):
changelog = Changelog() changelog = Changelog()
changelog.update(next_tag, commits) changelog.update(next_tag, commits)
Git("add", Changelog.FILENAME).exec(print="Agregando nuevo CHANGELOG.md") Git("add", Changelog.FILENAME).exec(print=None if ci else "Agregando nuevo CHANGELOG.md")
Git("commit", message=Changelog.COMMIT_MESSAGE).exec(print="Creando commit") Git("commit", message=Changelog.COMMIT_MESSAGE).exec(print=None if ci else "Creando commit")
tag_commit = Git("show", "HEAD", patch=False, format="%h").firstline() tag_commit = Git("show", "HEAD", patch=False, format="%h").firstline()
if ci: if ci:
Git("push").exec(print="Subiendo commit al remoto para taggearlo") Git("push").exec()
base.io_success(base.get_remote_api(token).create_tag(next_tag, tag_commit)) 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") Git("tag", next_tag, tag_commit).exec(print="Creando tag localmente")
@@ -81,24 +91,6 @@ def get_token_and_ci(token: Optional[str]):
return (base.ensure_repository_token(), False) 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( def get_next_tag_from_commits(
commits: list[str], suffix: str, current_tag: str | None commits: list[str], suffix: str, current_tag: str | None
) -> str | None: ) -> str | None: