feat(scripts): add type extraction and mismatch detection logic
All checks were successful
Auto Changelog & Release / release (push) Successful in 12s
All checks were successful
Auto Changelog & Release / release (push) Successful in 12s
This commit is contained in:
@@ -2,6 +2,11 @@
|
|||||||
import json
|
import json
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
import re
|
||||||
|
|
||||||
|
def extract_type(raw_message: str) -> str | None:
|
||||||
|
m = re.match(r"^(\w+)(?:\([^)]+\))?:", raw_message.strip())
|
||||||
|
return m.group(1) if m else None
|
||||||
|
|
||||||
def git_commits_between(parent, merge):
|
def git_commits_between(parent, merge):
|
||||||
"""Return list of commit hashes between parent and merge (exclusive of parent, inclusive of merge)."""
|
"""Return list of commit hashes between parent and merge (exclusive of parent, inclusive of merge)."""
|
||||||
@@ -34,6 +39,8 @@ def main(path=None):
|
|||||||
).strip().split()
|
).strip().split()
|
||||||
merge_id, *parent_ids = parents
|
merge_id, *parent_ids = parents
|
||||||
|
|
||||||
|
parent_type = extract_type(c["raw_message"])
|
||||||
|
|
||||||
if len(parent_ids) >= 2:
|
if len(parent_ids) >= 2:
|
||||||
mainline = parent_ids[0]
|
mainline = parent_ids[0]
|
||||||
children_ids = git_commits_between(mainline, merge_id)
|
children_ids = git_commits_between(mainline, merge_id)
|
||||||
@@ -41,7 +48,13 @@ def main(path=None):
|
|||||||
children = []
|
children = []
|
||||||
for cid in children_ids:
|
for cid in children_ids:
|
||||||
if cid in commits_by_id:
|
if cid in commits_by_id:
|
||||||
children.append(commits_by_id[cid])
|
child = commits_by_id[cid]
|
||||||
|
child_type = extract_type(child["raw_message"])
|
||||||
|
if child_type and parent_type and child_type != parent_type:
|
||||||
|
if not child.get("extra") or not isinstance(child["extra"], dict):
|
||||||
|
child["extra"] = {}
|
||||||
|
child["extra"]["mismatch_type"] = child_type
|
||||||
|
children.append(child)
|
||||||
consumed.add(cid)
|
consumed.add(cid)
|
||||||
|
|
||||||
if not c.get("extra") or not isinstance(c["extra"], dict):
|
if not c.get("extra") or not isinstance(c["extra"], dict):
|
||||||
|
|||||||
Reference in New Issue
Block a user