|
|
@@ -16,20 +16,15 @@ app = typer.Typer()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.command()
|
|
|
|
@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."""
|
|
|
|
"""Crea un nuevo tag para el último merge."""
|
|
|
|
base.ensure_initialized()
|
|
|
|
base.ensure_initialized()
|
|
|
|
|
|
|
|
|
|
|
|
target = Git.get_current_branch()
|
|
|
|
target = target or Git.get_current_branch()
|
|
|
|
|
|
|
|
|
|
|
|
if target not in base.environments:
|
|
|
|
if target not in base.environments:
|
|
|
|
raise GitFlowError("Solo se pueden taggear commits en ramas principales.")
|
|
|
|
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(
|
|
|
|
merge_commit = Git(
|
|
|
|
"log", first_parent=True, merges=True, max_count=1, format="%H"
|
|
|
|
"log", first_parent=True, merges=True, max_count=1, format="%H"
|
|
|
|
).firstline()
|
|
|
|
).firstline()
|
|
|
@@ -37,6 +32,19 @@ def tag(token: str | None = None, update_changelog: bool = False):
|
|
|
|
if not merge_commit:
|
|
|
|
if not merge_commit:
|
|
|
|
raise GitFlowError("No hay merges a taggear.")
|
|
|
|
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
|
|
|
|
# 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 ""
|
|
|
|
|
|
|
|
|
|
|
@@ -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)
|
|
|
|
current_tag = base.get_remote_api(token).get_latest_tag(suffix)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
# Commits se obtienen del último merge, listando hasta el primer forkpoint
|
|
|
|
# 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)
|
|
|
|
fork_point = Git.get_first_fork_point(branch, target)
|
|
|
|
commits = Git.get_commits(fork_point, branch)
|
|
|
|
commits = Git.get_commits(fork_point, branch)
|
|
|
|
# Último tag se obtiene localmente
|
|
|
|
# Último tag se obtiene localmente
|
|
|
@@ -74,7 +82,7 @@ def tag(token: str | None = None, update_changelog: bool = False):
|
|
|
|
if ci:
|
|
|
|
if ci:
|
|
|
|
Git("push").exec()
|
|
|
|
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:
|
|
|
|
if ci:
|
|
|
|
base.io_success(base.get_remote_api(token).create_tag(next_tag, tag_commit))
|
|
|
|
base.io_success(base.get_remote_api(token).create_tag(next_tag, tag_commit))
|
|
|
|