diff --git a/git-flow b/git-flow index 73d0ebc..e1590a3 100755 --- a/git-flow +++ b/git-flow @@ -479,7 +479,7 @@ def update_changelog(branch: str, target: str): return True -def generate_changelog_entry(branch: str, target: str): +def get_changelog_header_lines(branch: str): name = Git("config", "user.name").firstline() email = Git("config", "user.email").firstline() @@ -488,20 +488,26 @@ def generate_changelog_entry(branch: str, target: str): month = now.strftime("%B").capitalize() timestamp = now.strftime(f"{weekday}, %e de {month} de %Y, %H:%M") - entry_lines = [ + return [ f"## {timestamp}", "", - "### Autor", - "", - f"- Usuario: **{name}**", - f"- Email: **{email}**", - "", - "### Commits", - "", - f"Rama: **{branch}**", + f"- Autor: [{name}](mailto:{email})", + f"- Rama: `{branch}`", + "" + "### Commits" "" ] +def get_changelog_footer_lines(): + return [ + "", + "---", + "", + "" + ] + +def generate_changelog_entry(branch: str, target: str): + entry_lines = get_changelog_header_lines(branch) commits = Git("log", target + "..", first_parent=True, format="%h", merges=False).lines() for commit in commits: @@ -521,12 +527,7 @@ def generate_changelog_entry(branch: str, target: str): [status, filename] = diff.split("\t") entry_lines.append(f"\t- {filename} ({status})") - entry_lines += [ - "", - "---", - "", - "" - ] + entry_lines += get_changelog_footer_lines() return "\n".join(entry_lines) @@ -535,7 +536,9 @@ def create_pull_request(service: str, repository: str, source: str, destination: endpoint = get_api_endpoint(service, repository, "/pullrequests") title = source.replace("/", ": ").replace("-", " ") lines = generate_changelog_entry(source, destination).splitlines() - description = "\n".join(lines[3:-4]) + header_lines = get_changelog_header_lines(source) + footer_lines = get_changelog_footer_lines() + description = "\n".join(lines[len(header_lines):-len(footer_lines)]) headers = get_headers() json = {