fix: skip ci and readme-only commits in changelog
This commit is contained in:
@@ -112,6 +112,30 @@ def commit_has_tracked_changes(commit_hash: str) -> bool:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def commit_has_skip_ci_message(commit_hash: str) -> bool:
|
||||||
|
"""Check if commit message contains [skip ci] or similar."""
|
||||||
|
result = subprocess.run(
|
||||||
|
["git", "log", "-1", "--format=%s", commit_hash],
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
cwd=get_project_root(),
|
||||||
|
)
|
||||||
|
msg = result.stdout.strip().lower()
|
||||||
|
return "[skip ci]" in msg or "[skip-ci]" in msg or "[ci skip]" in msg
|
||||||
|
|
||||||
|
|
||||||
|
def commit_only_changes_readme(commit_hash: str) -> bool:
|
||||||
|
"""Check if commit only changes README.md."""
|
||||||
|
result = subprocess.run(
|
||||||
|
["git", "diff-tree", "--no-commit-id", "--name-only", "-r", commit_hash],
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
cwd=get_project_root(),
|
||||||
|
)
|
||||||
|
files = [f.strip() for f in result.stdout.strip().split("\n") if f.strip()]
|
||||||
|
return files == ["README.md"]
|
||||||
|
|
||||||
|
|
||||||
def get_commits_since_tag(tag: str | None) -> list[dict[str, str]]:
|
def get_commits_since_tag(tag: str | None) -> list[dict[str, str]]:
|
||||||
"""Get commits since last tag (only commits with tracked file changes)."""
|
"""Get commits since last tag (only commits with tracked file changes)."""
|
||||||
if tag:
|
if tag:
|
||||||
@@ -134,12 +158,19 @@ def get_commits_since_tag(tag: str | None) -> list[dict[str, str]]:
|
|||||||
if line:
|
if line:
|
||||||
parts = line.split("|")
|
parts = line.split("|")
|
||||||
if len(parts) >= 4:
|
if len(parts) >= 4:
|
||||||
|
commit_hash = parts[0]
|
||||||
|
# Skip commits with [skip ci] in message
|
||||||
|
if commit_has_skip_ci_message(commit_hash):
|
||||||
|
continue
|
||||||
|
# Skip commits that only change README.md
|
||||||
|
if commit_only_changes_readme(commit_hash):
|
||||||
|
continue
|
||||||
# Skip commits that only change ignored files
|
# Skip commits that only change ignored files
|
||||||
if not commit_has_tracked_changes(parts[0]):
|
if not commit_has_tracked_changes(commit_hash):
|
||||||
continue
|
continue
|
||||||
commits.append(
|
commits.append(
|
||||||
{
|
{
|
||||||
"hash": parts[0][:7],
|
"hash": commit_hash[:7],
|
||||||
"message": parts[1],
|
"message": parts[1],
|
||||||
"date": parts[2],
|
"date": parts[2],
|
||||||
"author": parts[3],
|
"author": parts[3],
|
||||||
|
|||||||
Reference in New Issue
Block a user