feature: tag from ci fetches commits from remote api

This commit is contained in:
Jonathan Teran Carballo
2026-09-20 21:05:21 -03:00
parent 889109bf77
commit 26ab81b175
8 changed files with 195 additions and 31 deletions
+10 -13
View File
@@ -1,15 +1,15 @@
from datetime import datetime
from os.path import isfile
from git_flow.git import Git
from git_flow.git import Commit
class Changelog:
FILENAME = "CHANGELOG.md"
COMMIT_MESSAGE = "chore: bump version and update CHANGELOG.md [skip ci]"
def update(self, title: str, base: str, branch: str):
self._prepend(self.generate_entry(title, base, branch))
def update(self, title: str, commits: list[Commit]):
self._prepend(self.generate_entry(title, commits))
def generate_header(self, title):
now = datetime.now()
@@ -18,16 +18,13 @@ class Changelog:
"""
def generate_content(self, base: str, branch: str):
commits = Git(
"log", base + ".." + branch, first_parent=True, format="%h", merges=False
).lines()
def generate_content(self, commits: list[Commit]):
content = ""
for commit in commits:
message = Git("show", commit, patch=False, format="%s").firstline()
email = Git("show", commit, patch=False, format="%ae").firstline()
username = email[: email.index("@")]
message = commit.subject
email = commit.email
username = email[: email.index("@")] if "@" in email else email
description = message
if ":" in message:
@@ -36,7 +33,7 @@ class Changelog:
commit_message = message[index + 1 :]
description = f"**{commit_type}**: {commit_message}"
content += f"- {description} [[{username}](mailto:{email})] ({commit})\n"
content += f"- {description} [[{username}](mailto:{email})] ({commit.sha})\n"
return content
@@ -47,10 +44,10 @@ class Changelog:
"""
def generate_entry(self, title: str, base: str, branch: str):
def generate_entry(self, title: str, commits: list[Commit]):
return (
self.generate_header(title)
+ self.generate_content(base, branch)
+ self.generate_content(commits)
+ self.generate_footer()
)