diff --git a/scripts/update_changelog.py b/scripts/update_changelog.py index aa48399..bb6b602 100644 --- a/scripts/update_changelog.py +++ b/scripts/update_changelog.py @@ -41,7 +41,12 @@ def get_last_tag(): def categorize_commit(commit_msg): """Categorize commit messages based on conventional commits""" lower_msg = commit_msg.lower() - if any(x in lower_msg for x in ['feat', 'add', 'new']): + + # Check for breaking changes first + if ('!' in commit_msg and any(x in lower_msg for x in ['feat!', 'fix!', 'chore!', 'refactor!'])) or \ + 'breaking change' in lower_msg or 'breaking:' in lower_msg: + return 'Breaking Changes' + elif any(x in lower_msg for x in ['feat', 'add', 'new']): return 'Added' elif any(x in lower_msg for x in ['fix', 'bug']): return 'Fixed' @@ -51,6 +56,7 @@ def categorize_commit(commit_msg): def get_changes_from_git(): """Get changes from git commits since last tag""" changes = { + 'Breaking Changes': [], 'Added': [], 'Changed': [], 'Fixed': [] @@ -72,7 +78,9 @@ def get_changes_from_git(): if commit: category = categorize_commit(commit) # Clean up commit message - clean_msg = re.sub(r'^(feat|fix|chore|docs|style|refactor|perf|test)(\(.*\))?:', '', commit).strip() + clean_msg = re.sub(r'^(feat|fix|chore|docs|style|refactor|perf|test)(\(.*\))?!?:', '', commit).strip() + # Remove BREAKING CHANGE prefix if present + clean_msg = re.sub(r'^breaking change:\s*', '', clean_msg, flags=re.IGNORECASE).strip() changes[category].append(clean_msg) except subprocess.CalledProcessError: