Skip to content

Commit 2ab2427

Browse files
committed
✨ feat(changelog): add up-to-date and empty change checks
1 parent 4c38ef9 commit 2ab2427

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tgit/changelog.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,18 @@ def handle_changelog(args: ChangelogArgs, current_tag: str | None = None) -> Non
423423
segments = prepare_changelog_segments(repo, latest_tag_in_file, current_tag)
424424
prepend = bool(latest_tag_in_file)
425425

426+
# 检查是否有新的更改需要生成 changelog
427+
if not segments:
428+
if latest_tag_in_file:
429+
# 检查文件中的最新 tag 是否已经是仓库中的最新 tag
430+
latest_repo_tag = get_latest_git_tag(repo)
431+
if latest_tag_in_file == latest_repo_tag:
432+
print("[green]Changelog is already up to date.[/green]")
433+
return
434+
else:
435+
print("[yellow]No changes found, nothing to output.[/yellow]")
436+
return
437+
426438
# 生成 changelog
427439
changelogs = _generate_changelogs_from_segments(repo, segments)
428440

@@ -449,6 +461,9 @@ def _get_range_segments(repo: git.Repo, from_raw: str | None, to_raw: str | None
449461

450462
def _generate_changelogs_from_segments(repo: git.Repo, segments: list[VersionSegment]) -> str:
451463
"""从分段列表生成 changelog"""
464+
if not segments:
465+
return ""
466+
452467
changelogs = ""
453468

454469
with Progress() as progress:

0 commit comments

Comments
 (0)