feature: when merging environments, promote tag from previous env to next env

This commit is contained in:
Jonathan Teran
2026-09-24 12:06:19 -03:00
parent 631c507064
commit 44fa8bc1d6
8 changed files with 117 additions and 35 deletions
+21 -2
View File
@@ -73,6 +73,21 @@ class Git:
exclude=None if suffix else "*-*",
).firstline(check=False, print="Obteniendo tag actual")
@staticmethod
def get_promoted_tag(merge_commit: str, suffix: str) -> str | None:
"""Si el merge trae tags con el sufijo indicado que la rama destino no tenía (por ejemplo,
un merge de dev a test trae tags *-dev nuevos), devuelve el más alto de ellos."""
tags = Git(
"tag",
"v[0-9]*.[0-9]*.[0-9]*" + suffix,
list=True,
merged=merge_commit + "^2",
no_merged=merge_commit + "^1",
sort="-v:refname",
).lines()
return tags[0] if tags else None
@staticmethod
def get_first_fork_point(branch: str, env: str):
# Lista de commits alcanzables por el entorno (por ejemplo, dev),
@@ -84,10 +99,14 @@ class Git:
return Git("show", env_commits[-1] + "^", patch=False, format="%h").firstline()
@staticmethod
def get_commits(base: str, branch: str) -> list[Commit]:
def get_commits(base: str, branch: str, first_parent: bool = True) -> list[Commit]:
"""Commits propios de la rama (sin merges), del más nuevo al más viejo."""
lines = Git(
"log", base + ".." + branch, first_parent=True, merges=False, format="%h%x09%ae%x09%s"
"log",
base + ".." + branch,
first_parent=first_parent or None,
merges=False,
format="%h%x09%ae%x09%s",
).lines()
commits = []