Skip to content

Commit 15237ca

Browse files
committed
✨ feat(changelog): improve changelog output with panel ui
1 parent ca81836 commit 15237ca

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

tgit/changelog.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,15 @@ def print_and_write_changelog(
346346
print()
347347
# rich.Markdown 默认标题居中,需用 console.print 并设置参数 style 和 width
348348
md = Markdown(changelog.strip("\n"), justify="left")
349-
console.print(md, width=80)
349+
panel = Panel(
350+
md,
351+
title="Changelog",
352+
border_style="cyan",
353+
title_align="left",
354+
subtitle=f"It is saved to {output_path}" if output_path else None,
355+
width=80,
356+
)
357+
console.print(panel)
350358
if output_path:
351359
if prepend:
352360
write_changelog_prepend(output_path, changelog)
@@ -456,14 +464,4 @@ def get_changelog_by_range(repo: git.Repo, from_ref: str, to_ref: str) -> str:
456464
def get_git_commits_range(repo: git.Repo, from_raw: str, to_raw: str) -> tuple[str, str]:
457465
from_ref = resolve_from_ref(repo, from_raw)
458466
to_ref = "HEAD" if to_raw is None else to_raw
459-
if to_ref == "HEAD":
460-
latest_commit = repo.head.commit
461-
tags = repo.tags
462-
latest_commit_tags = [tag for tag in tags if tag.commit == latest_commit]
463-
if latest_commit_tags:
464-
to_ref = from_ref
465-
from_ref = get_tag_by_idx(repo, -2)
466-
if from_ref is None:
467-
from_ref = get_first_commit_hash(repo)
468-
469467
return from_ref, to_ref

0 commit comments

Comments
 (0)