feature: cambio merge y tag para que el changelog se genere al crear un tag nuevo

This commit is contained in:
jt
2025-11-19 20:43:22 -03:00
parent 30c6c36beb
commit be87c2098b
15 changed files with 1036 additions and 233 deletions
+51 -21
View File
@@ -1,30 +1,50 @@
import subprocess
from .io import *
from git_flow.io import *
class Status:
worktree: str
index: str
file: str
FLOWCONFIG_FILE = ".flowconfig"
def __init__(self, line: str) -> None:
self.worktree = line[0]
self.index = line[1]
self.file = line[3:].strip("\n")
CHANGELOG_FILE = "CHANGELOG.md"
BUMP_VERSION = "chore: bump version and update CHANGELOG.md [skip ci]"
class Git:
FLOWCONFIG_FILE = ".flowconfig"
CHANGELOG_FILE = "CHANGELOG.md"
BUMP_VERSION = "chore: bump version and update CHANGELOG.md [skip ci]"
class Status:
worktree: str
index: str
file: str
def __init__(self, line: str) -> None:
self.worktree = line[0]
self.index = line[1]
self.file = line[3:].strip("\n")
command: list[str]
check_returncode: bool = True
@staticmethod
def get_config(file: str | None = None):
config: dict[str, str] = {}
lines = Git("config", file=file, list=True).lines()
for line in lines:
pos = line.index("=")
key = line[:pos]
value = line[pos + 1 :]
config[key] = value
return config
@staticmethod
def set_config(config: dict[str, str], file: str | None = None):
for key, value in config:
Git("config", key, value, file=file).exec()
@staticmethod
def flow_config(*args, **kwargs):
return Git("config", *args, file=Git.FLOWCONFIG_FILE, **kwargs)
return Git("config", *args, file=FLOWCONFIG_FILE, **kwargs)
@staticmethod
def get_current_branch():
@@ -36,7 +56,7 @@ class Git:
@staticmethod
def status():
return list(map(Status, Git("status", porcelain=True).lines(False)))
return list(map(Git.Status, Git("status", porcelain=True).lines(False)))
@staticmethod
def get_current_tag():
@@ -44,10 +64,14 @@ class Git:
@staticmethod
def get_first_fork_point(branch: str, env: str):
boundary_commits = list(filter(
lambda c: c.startswith("-"), # boundary commits
Git("rev-list", env + "..." + branch, topo_order=True, boundary=True).lines()
))
boundary_commits = list(
filter(
lambda c: c.startswith("-"), # boundary commits
Git(
"rev-list", env + "..." + branch, topo_order=True, boundary=True
).lines(),
)
)
if not boundary_commits:
raise RuntimeError("No se encontro un commit base para realizar el rebase.")
@@ -57,12 +81,16 @@ class Git:
@staticmethod
def _get_references(kind: str):
prefix = "refs/" + kind + "/"
return map(
return list(map(
lambda r: r.removeprefix(prefix),
Git("for-each-ref", prefix + "*", format="%(refname)").lines(),
)
))
def __init__(self, subcommand: str, *args: str, **kwargs: str | int | bool) -> None:
@staticmethod
def is_repository() -> bool:
return Git("rev-parse", is_inside_work_tree=True).code() == 0
def __init__(self, subcommand: str, *args: str, **kwargs: str | int | bool | None) -> None:
self.command = ["git", subcommand]
for option, value in kwargs.items():
@@ -74,6 +102,8 @@ class Git:
else:
prefix = "--" if value else "--no-"
self.command.append(prefix + option)
elif value is None:
continue
else:
value = value if isinstance(value, str) else str(value)