fix: enhance commit categorization for breaking changes
This commit is contained in:
		| @@ -41,7 +41,12 @@ def get_last_tag(): | |||||||
| def categorize_commit(commit_msg): | def categorize_commit(commit_msg): | ||||||
|     """Categorize commit messages based on conventional commits""" |     """Categorize commit messages based on conventional commits""" | ||||||
|     lower_msg = commit_msg.lower() |     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' |         return 'Added' | ||||||
|     elif any(x in lower_msg for x in ['fix', 'bug']): |     elif any(x in lower_msg for x in ['fix', 'bug']): | ||||||
|         return 'Fixed' |         return 'Fixed' | ||||||
| @@ -51,6 +56,7 @@ def categorize_commit(commit_msg): | |||||||
| def get_changes_from_git(): | def get_changes_from_git(): | ||||||
|     """Get changes from git commits since last tag""" |     """Get changes from git commits since last tag""" | ||||||
|     changes = { |     changes = { | ||||||
|  |         'Breaking Changes': [], | ||||||
|         'Added': [], |         'Added': [], | ||||||
|         'Changed': [], |         'Changed': [], | ||||||
|         'Fixed': [] |         'Fixed': [] | ||||||
| @@ -72,7 +78,9 @@ def get_changes_from_git(): | |||||||
|             if commit: |             if commit: | ||||||
|                 category = categorize_commit(commit) |                 category = categorize_commit(commit) | ||||||
|                 # Clean up commit message |                 # 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) |                 changes[category].append(clean_msg) | ||||||
|                  |                  | ||||||
|     except subprocess.CalledProcessError: |     except subprocess.CalledProcessError: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user