Compare commits

...
25 Commits
Author SHA1 Message Date
bitbucket-pipelines f4b47000a6 chore: bump version and update CHANGELOG.md [skip ci] 2025-12-11 18:18:23 +00:00
JonathanGitFlowandjt b12d2a1930 Merged in bugfix/first-fork-point-getter (pull request #46)
bugfix: first fork point getter

Approved-by: Jonathan Teran
2025-12-11 18:17:53 +00:00
Jonathan Teran Carballo 7b4fb34ef3 bugfix: cambio la forma en la que se obtiene el first fork point entre 2 ramas 2025-12-11 15:15:45 -03:00
bitbucket-pipelines 6a758cdb94 chore: bump version and update CHANGELOG.md [skip ci] 2025-12-11 12:55:31 +00:00
JonathanGitFlowandjt b148a9f71d Merged in feature/show-commit-list-on-release (pull request #45)
feature: show commit list on release

Approved-by: Jonathan Teran
2025-12-11 12:55:01 +00:00
Jonathan Teran 2e65cb7a3e feature: muestro el listado de commits a pasar al siguiente entorno en release 2025-12-11 09:53:41 -03:00
bitbucket-pipelines 9c8df34a09 chore: bump version and update CHANGELOG.md [skip ci] 2025-12-10 18:29:40 +00:00
JonathanGitFlowandjt 89f8bc58ba Merged in bugfix/commit-list-for-merge (pull request #44)
bugfix: commit list for merge

Approved-by: Jonathan Teran
2025-12-10 18:29:07 +00:00
Jonathan Teran 4e089dc4d6 bugfix: cambio la lista de commits a mostrar en el merge 2025-12-10 15:06:21 -03:00
Jonathan Teran c8e1a7cc88 chore: bump version and update CHANGELOG.md [skip ci] 2025-12-04 10:19:54 -03:00
JonathanGitFlowandjt 65be7a01f0 Merged in bugfix/tag-name-scheme (pull request #43)
bugfix: tag name scheme

Approved-by: Jonathan Teran
2025-12-04 13:17:52 +00:00
Jonathan Teran 7ce6addf07 bugfix: revertir guion entre version y entorno, agregar guion a sufijo 2025-12-04 10:17:26 -03:00
bitbucket-pipelines 824b5f06de chore: bump version and update CHANGELOG.md [skip ci] 2025-12-04 13:16:27 +00:00
JonathanGitFlowandjt 9937f4b6bc Merged in bugfix/tag-name-scheme (pull request #42)
bugfix: tag name scheme

Approved-by: Jonathan Teran
2025-12-04 13:15:56 +00:00
Jonathan Teran 053b8b102b bugfix: agrego guion entre version y nombre de entorno 2025-12-04 10:15:32 -03:00
bitbucket-pipelines a2475195b2 chore: bump version and update CHANGELOG.md [skip ci] 2025-12-04 13:13:42 +00:00
JonathanGitFlowandjt 603519bf39 Merged in bugfix/create-changelog-when-missing (pull request #41)
bugfix: create changelog when missing

Approved-by: Jonathan Teran
2025-12-04 13:13:14 +00:00
Jonathan Teran 0c8e7bb37a bugfix: crear changelog cuando no existe 2025-12-04 10:11:10 -03:00
bitbucket-pipelines 6643271747 chore: bump version and update CHANGELOG.md [skip ci] 2025-11-29 16:41:43 +00:00
JonathanGitFlowandjt 68e11c66d1 Merged in bugfix/group-release-confirmation-and-commits-squash-count (pull request #40)
bugfix: group release confirmation and commits squash count

Approved-by: Jonathan Teran
2025-11-29 16:41:19 +00:00
jt f1f6e6724c bugfix: arreglo mensaje de confirmacion de squash, muevo prompt de commit message antes del squash 2025-11-29 13:40:34 -03:00
jt 83df7e9553 bugfix: cambio default en confirmacion para agrupar release 2025-11-29 13:35:25 -03:00
bitbucket-pipelines f5e683a1da chore: bump version and update CHANGELOG.md [skip ci] 2025-11-29 16:22:03 +00:00
JonathanGitFlowandjt fb9b8b57f6 Merged in feature/release-branch-groups (pull request #39)
feature: release branch groups

Approved-by: Jonathan Teran
2025-11-29 16:21:39 +00:00
jt c47afffa14 feature: agrego opcion para agrupar ramas release 2025-11-29 13:20:33 -03:00
6 changed files with 126 additions and 46 deletions
+62
View File
@@ -1,3 +1,65 @@
## v1.7.1 - 2025-12-11
- **bugfix**: cambio la forma en la que se obtiene el first fork point entre 2 ramas [[jteran](mailto:jteran@renatre.org.ar)] (7b4fb34)
---
## v1.7.0 - 2025-12-11
- **feature**: muestro el listado de commits a pasar al siguiente entorno en release [[jteran](mailto:jteran@renatre.org.ar)] (2e65cb7)
---
## v1.6.4 - 2025-12-10
- **bugfix**: cambio la lista de commits a mostrar en el merge [[jteran](mailto:jteran@renatre.org.ar)] (4e089dc)
---
## v1.6.3 - 2025-12-04
- **bugfix**: revertir guion entre version y entorno, agregar guion a sufijo [[jteran](mailto:jteran@renatre.org.ar)] (7ce6add)
- **bugfix**: agrego guion entre version y nombre de entorno [[jteran](mailto:jteran@renatre.org.ar)] (053b8b1)
---
## v1.6.3- - 2025-12-04
- **bugfix**: agrego guion entre version y nombre de entorno [[jteran](mailto:jteran@renatre.org.ar)] (053b8b1)
---
## v1.6.2 - 2025-12-04
- **bugfix**: crear changelog cuando no existe [[jteran](mailto:jteran@renatre.org.ar)] (0c8e7bb)
---
## v1.6.1 - 2025-11-29
### Commits
- **bugfix**: arreglo mensaje de confirmacion de squash, muevo prompt de commit message antes del squash [[jonathan.nerat](mailto:jonathan.nerat@gmail.com)] (f1f6e67)
- **bugfix**: cambio default en confirmacion para agrupar release [[jonathan.nerat](mailto:jonathan.nerat@gmail.com)] (83df7e9)
---
## v1.6.0 - 2025-11-29
### Commits
- **feature**: agrego opcion para agrupar ramas release [[jonathan.nerat](mailto:jonathan.nerat@gmail.com)] (c47afff)
---
## v1.5.2 - 2025-11-28 ## v1.5.2 - 2025-11-28
### Commits ### Commits
+1 -2
View File
@@ -16,8 +16,6 @@ class Changelog:
return f"""## {title} - {now.strftime("%F")} return f"""## {title} - {now.strftime("%F")}
### Commits
""" """
def generate_content(self, base: str, branch: str): def generate_content(self, base: str, branch: str):
@@ -56,5 +54,6 @@ class Changelog:
if isfile(self.FILENAME): if isfile(self.FILENAME):
with open(self.FILENAME, "r") as f: with open(self.FILENAME, "r") as f:
content += f.read() content += f.read()
with open(self.FILENAME, "w") as f: with open(self.FILENAME, "w") as f:
f.write(content) f.write(content)
+11 -12
View File
@@ -17,16 +17,15 @@ class MergeCommand(Command):
branch = self.ensure_right_branch() branch = self.ensure_right_branch()
(target, _) = self.get_branch_env_and_type(branch) (target, _) = self.get_branch_env_and_type(branch)
base = Git.get_first_fork_point(branch, target)
if "flow.remote" in self.flowconfig: if "flow.remote" in self.flowconfig:
remote = self.flowconfig["flow.remote"] remote = self.flowconfig["flow.remote"]
token = self.ensure_repository_token() token = self.ensure_repository_token()
self.run_remote(remote, token, base, branch, target) self.run_remote(remote, token, branch, target)
else: else:
self.run_local(base, branch, target) self.run_local(branch, target)
def run_remote(self, remote: str, token: str, base: str, branch: str, target: str): def run_remote(self, remote: str, token: str, branch: str, target: str):
self.ensure_clean_worktree(True) self.ensure_clean_worktree(True)
Git("switch", target).exec(print="Cambiando a rama destino") Git("switch", target).exec(print="Cambiando a rama destino")
@@ -34,26 +33,26 @@ class MergeCommand(Command):
Git("switch", "-").exec(print="Volviendo a rama a mergear") Git("switch", "-").exec(print="Volviendo a rama a mergear")
self.check_merge_conflicts(target) self.check_merge_conflicts(target)
self.show_commits_to_merge(base) self.show_commits_to_merge(target)
if self.confirm(f"¿Crear PR de '{branch}' a '{target}'?"): if self.confirm(f"¿Crear PR de '{branch}' a '{target}'?"):
Git("push", remote, branch, set_upstream=True).exec( Git("push", remote, branch, set_upstream=True).exec(
print="Subiendo rama al remoto para crear PR" print="Subiendo rama al remoto para crear PR"
) )
self.create_pull_request(token, base, branch, target) self.create_pull_request(token, branch, target)
def run_local(self, base: str, branch: str, target: str): def run_local(self, branch: str, target: str):
self.ensure_clean_worktree(False) self.ensure_clean_worktree(False)
self.check_merge_conflicts(target) self.check_merge_conflicts(target)
self.show_commits_to_merge(base) self.show_commits_to_merge(target)
if self.confirm(f"¿Mergear rama '{branch}' a '{target}'?"): if self.confirm(f"¿Mergear rama '{branch}' a '{target}'?"):
Git("switch", target).exec(print="Cambiando a rama destino") Git("switch", target).exec(print="Cambiando a rama destino")
Git("merge", branch, ff=False).exec(print="Mergeando") Git("merge", branch, ff=False).exec(print="Mergeando")
def show_commits_to_merge(self, base): def show_commits_to_merge(self, target):
commits = Git("log", base + "..", format="%s").lines() commits = Git("log", target + "..", format="%s").lines()
if not commits: if not commits:
raise GitFlowError("No hay cambios a mergear.") raise GitFlowError("No hay cambios a mergear.")
@@ -79,14 +78,14 @@ class MergeCommand(Command):
else: else:
self.success("No se detectaron merge conflicts.") self.success("No se detectaron merge conflicts.")
def create_pull_request(self, token: str, base: str, branch: str, target: str): def create_pull_request(self, token: str, branch: str, target: str):
changelog = Changelog() changelog = Changelog()
message = self.get_remote_api(token).create_pull_request( message = self.get_remote_api(token).create_pull_request(
branch, branch,
target, target,
branch.replace("/", ": ").replace("-", " "), branch.replace("/", ": ").replace("-", " "),
changelog.generate_content(base, branch), changelog.generate_content(target, branch),
) )
self.success(message) self.success(message)
+42 -16
View File
@@ -1,4 +1,4 @@
from argparse import Namespace from argparse import ArgumentParser, Namespace
from git_flow import COMMIT_TYPES, GitFlowError from git_flow import COMMIT_TYPES, GitFlowError
from git_flow.command.base import Command from git_flow.command.base import Command
from git_flow.git import Git from git_flow.git import Git
@@ -11,6 +11,15 @@ class ReleaseCommand(Command):
def description(self) -> str: def description(self) -> str:
return """Realiza el merge de la rama, o crea el PR para hacerlo si tiene un remoto configurado""" return """Realiza el merge de la rama, o crea el PR para hacerlo si tiene un remoto configurado"""
def setup_parser(self, parser: ArgumentParser) -> ArgumentParser:
parser.add_argument(
"--group",
nargs="?",
help="Agrupar release",
)
return parser
def run(self, args: Namespace = Namespace()): def run(self, args: Namespace = Namespace()):
self.ensure_initialized() self.ensure_initialized()
@@ -34,34 +43,51 @@ class ReleaseCommand(Command):
else f"release/{next_env}/{branch}" else f"release/{next_env}/{branch}"
) )
base = Git.get_first_fork_point(branch, env)
commits = Git("log", base + ".." , format="%s").lines()
if not commits:
raise GitFlowError("No hay cambios a mergear.")
print("Cambios a pasar al proximo entorno:")
for commit in commits:
print("- " + commit)
group = args.group
if not group and self.confirm("¿Desea agrupar este release con otra rama?", False):
group = self.choice("Grupo release: ", Git.get_branches("release/" + next_env + "/"))
else:
group = next_env
if has_remote: if has_remote:
Git("pull").exec(print="Sincronizando cambios de la rama") Git("switch", group).exec(print="Cambiando a la rama objetivo")
Git("switch", next_env).exec(print="Cambiando al siguiente entorno") Git("pull").exec(print="Sincronizando cambios la rama objetivo")
Git("pull").exec(print="Sincronizando cambios del entorno")
Git("switch", "-").exec(print="Volviendo a la rama original") Git("switch", "-").exec(print="Volviendo a la rama original")
base = Git.get_first_fork_point(branch, env) if len(commits) > 1 and self.confirm(
commits = int(Git("rev-list", base + "..", count=True).firstline()) f"¿Desea reemplazar los {len(commits)} commits de la rama por uno solo?",
False
if commits > 1 and self.confirm(
"Desea reemplazar los {commits} commits de la rama por uno solo?"
): ):
Git("switch", next_branch, base, create=True).exec( self.info("Debe ingresar el mensaje del commit a crear.")
print="Creando rama release en base"
)
Git("merge", branch, squash=True).exec(
print="Squasheando commits en uno solo"
)
commit_type = self.choice("Tipo de commit", COMMIT_TYPES[:-1]) commit_type = self.choice("Tipo de commit", COMMIT_TYPES[:-1])
commit_message = self.prompt( commit_message = self.prompt(
"Mensaje (máximo recomendado: 100 caracteres)", persistent=True "Mensaje (máximo recomendado: 100 caracteres)", persistent=True
) )
message = commit_type + ": " + commit_message message = commit_type + ": " + commit_message
Git("switch", next_branch, base, create=True).exec(
print="Creando rama release en base"
)
Git("merge", branch, squash=True).exec(
print="Squasheando commits en uno solo"
)
Git("commit", m=message).exec(print="Creando commit único") Git("commit", m=message).exec(print="Creando commit único")
else: else:
Git("switch", next_branch, create=True).exec(print="Creando rama release") Git("switch", next_branch, create=True).exec(print="Creando rama release")
Git("rebase", base, next_branch, onto=next_env).exec( Git("rebase", base, next_branch, onto=group).exec(
print="Moviendo cambios hacia el siguiente ambiente" print="Moviendo cambios hacia el siguiente ambiente"
) )
+1 -1
View File
@@ -91,7 +91,7 @@ class TagCommand(Command):
tag = Git.get_current_tag() or f"v0.0.0-{branch}" tag = Git.get_current_tag() or f"v0.0.0-{branch}"
until_dash = tag.index("-") if "-" in tag else None until_dash = tag.index("-") if "-" in tag else None
suffix = tag[until_dash + 1 :] if until_dash is not None else "" suffix = tag[until_dash:] if until_dash is not None else ""
[major, minor, patch] = map(int, tag[1:until_dash].split(".")) [major, minor, patch] = map(int, tag[1:until_dash].split("."))
if increment == SEMVER_MAJOR: if increment == SEMVER_MAJOR:
+7 -13
View File
@@ -50,8 +50,8 @@ class Git:
return Git("rev-parse", "HEAD", abbrev_ref=True).firstline() return Git("rev-parse", "HEAD", abbrev_ref=True).firstline()
@staticmethod @staticmethod
def get_branches(): def get_branches(prefix: str = ""):
return Git._get_references("heads") return Git._get_references("heads/" + prefix)
@staticmethod @staticmethod
def status(): def status():
@@ -63,23 +63,17 @@ class Git:
@staticmethod @staticmethod
def get_first_fork_point(branch: str, env: str): def get_first_fork_point(branch: str, env: str):
boundary_commits = list( # Lista de commits alcanzables por el entorno (por ejemplo, dev),
filter( env_commits = Git("rev-list", env + "..." + branch, first_parent=True).lines()
lambda c: c.startswith("-"), # boundary commits
Git(
"rev-list", env + "..." + branch, topo_order=True, boundary=True
).lines(),
)
)
if not boundary_commits: if not env_commits:
raise RuntimeError("No se encontro un commit base para realizar el rebase.") raise RuntimeError("No se encontro un commit base para realizar el rebase.")
return boundary_commits[-1].removeprefix("-") return Git("show", env_commits[-1] + "^", patch=False, format="%h").firstline()
@staticmethod @staticmethod
def _get_references(kind: str): def _get_references(kind: str):
prefix = "refs/" + kind + "/" prefix = "refs/" + kind
return list(map( return list(map(
lambda r: r.removeprefix(prefix), lambda r: r.removeprefix(prefix),
Git("for-each-ref", prefix + "*", format="%(refname)").lines(), Git("for-each-ref", prefix + "*", format="%(refname)").lines(),