Compare commits

..
8 Commits
Author SHA1 Message Date
jt 04c05ca8ce Merge pull request 'bugfix: check if merge commit already has a tag before tagging' (#55) from bugfix/check-merge-commit-tag into main
Publish to PyPI / Bump-Build-Publish (push) Successful in 18s
Reviewed-on: #55
2026-09-21 18:12:13 +00:00
jt 0d1ce5305b bugfix: check if merge commit already has a tag before tagging 2026-09-21 15:11:47 -03:00
jt a17d9c308a Merge pull request 'bugfix: get target from tag options' (#54) from bugfix/clean-tag-command into main
Publish to PyPI / Bump-Build-Publish (push) Successful in 19s
Reviewed-on: #54
2026-09-21 17:35:49 +00:00
jt 7121d40ed8 bugfix: get target from tag options 2026-09-21 14:35:27 -03:00
jt 41b7a9e602 Merge pull request 'bugfix: use full commit sha' (#53) from bugfix/clean-tag-command into main
Publish to PyPI / Bump-Build-Publish (push) Successful in 18s
Reviewed-on: #53
2026-09-21 17:18:57 +00:00
jt f35dbc126a bugfix: use full commit sha 2026-09-21 14:17:43 -03:00
jt 410c5f9356 Merge pull request 'bugfix: remove debug log' (#52) from bugfix/clean-tag-command into main
Publish to PyPI / Bump-Build-Publish (push) Successful in 19s
Reviewed-on: #52
2026-09-21 16:54:35 +00:00
jt 7a24ccb24c bugfix: remove debug log 2026-09-21 13:49:50 -03:00
2 changed files with 18 additions and 12 deletions
+17 -11
View File
@@ -16,20 +16,15 @@ app = typer.Typer()
@app.command()
def tag(token: str | None = None, update_changelog: bool = False):
def tag(target: str | None = None, token: str | None = None, update_changelog: bool = False):
"""Crea un nuevo tag para el último merge."""
base.ensure_initialized()
target = Git.get_current_branch()
target = target or Git.get_current_branch()
if target not in base.environments:
raise GitFlowError("Solo se pueden taggear commits en ramas principales.")
token, ci = get_token_and_ci(token)
if ci and not token:
raise GitFlowError("No hay token disponible")
merge_commit = Git(
"log", first_parent=True, merges=True, max_count=1, format="%H"
).firstline()
@@ -37,6 +32,19 @@ def tag(token: str | None = None, update_changelog: bool = False):
if not merge_commit:
raise GitFlowError("No hay merges a taggear.")
merge_commit_tag = Git("tag", "--points-at", merge_commit).firstline()
if merge_commit_tag:
base.io_info(f"El último merge ya tiene un tag: {merge_commit_tag}")
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 ""
token, ci = get_token_and_ci(token)
if ci and not token:
raise GitFlowError("No hay token disponible")
# 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 ""
@@ -48,7 +56,7 @@ def tag(token: str | None = None, update_changelog: bool = False):
current_tag = base.get_remote_api(token).get_latest_tag(suffix)
else:
# Commits se obtienen del último merge, listando hasta el primer forkpoint
branch = Git("show", merge_commit + "^2", patch=False, format="%h").firstline()
branch = Git("show", merge_commit + "^2", patch=False, format="%H").firstline()
fork_point = Git.get_first_fork_point(branch, target)
commits = Git.get_commits(fork_point, branch)
# Último tag se obtiene localmente
@@ -58,8 +66,6 @@ def tag(token: str | None = None, update_changelog: bool = False):
[c.subject for c in commits], suffix, current_tag
)
base.io_info(f"Current tag: {current_tag}. Next tag: {next_tag}")
if not next_tag:
base.io_warning(
"Los cambios realizados no implican un salto de versión, se mantiene la anterior."
@@ -76,7 +82,7 @@ def tag(token: str | None = None, update_changelog: bool = False):
if ci:
Git("push").exec()
tag_commit = Git("show", "HEAD", patch=False, format="%h").firstline()
tag_commit = Git("show", "HEAD", patch=False, format="%H").firstline()
if ci:
base.io_success(base.get_remote_api(token).create_tag(next_tag, tag_commit))
+1 -1
View File
@@ -46,7 +46,7 @@ class GitlabRemoteAPI(RemoteAPI):
if response.ok:
return "Tag creado exitosamente: " + tag
else:
raise GitFlowError("Ocurrió un error al crear el tag para repositorio " + quote(self.repository, safe="") + ": " + response.text)
raise GitFlowError("Ocurrió un error al crear el tag: " + response.text)
def get_merge_commits(self, merge_commit: str) -> list[Commit]:
mrs = self.get_json(