🎨 代码格式化
Hello from ImmortalWrt / say-hello (push) Successful in 0s
Details
Hello from ImmortalWrt / say-hello (push) Successful in 0s
Details
:fix: 修复识别`CHANGELOG`标题问题
This commit is contained in:
parent
84e2751668
commit
ec5785cc6a
|
|
@ -571,16 +571,44 @@ jobs:
|
|||
new_content = existing_content[:match.start()] + updated_section + existing_content[match.end():]
|
||||
else:
|
||||
print("⚠️ Could not find version section, prepending new content")
|
||||
new_content = existing_content.replace(
|
||||
"# :memo: CHANGELOG\n\n",
|
||||
f"# :memo: CHANGELOG\n\n{changelog_content}"
|
||||
)
|
||||
# 尝试匹配各种可能的 CHANGELOG 标题格式
|
||||
header_pattern = r'^#\s*(?::[\w_]+:)?\s*CHANGELOG\s*\n'
|
||||
match = re.search(header_pattern, existing_content, re.IGNORECASE | re.MULTILINE)
|
||||
|
||||
if match:
|
||||
insert_pos = match.end()
|
||||
if not existing_content[insert_pos:insert_pos+1] == '\n':
|
||||
new_content = existing_content[:insert_pos] + '\n' + changelog_content + existing_content[insert_pos:]
|
||||
else:
|
||||
new_content = existing_content[:insert_pos] + '\n' + changelog_content + existing_content[insert_pos+1:]
|
||||
else:
|
||||
# 没有找到标题,在开头插入
|
||||
new_content = f"# :memo: CHANGELOG\n\n{changelog_content}{existing_content}"
|
||||
else:
|
||||
# 插入新版本
|
||||
new_content = existing_content.replace(
|
||||
"# :memo: CHANGELOG\n\n",
|
||||
f"# :memo: CHANGELOG\n\n{changelog_content}"
|
||||
)
|
||||
# 尝试匹配各种可能的 CHANGELOG 标题格式
|
||||
# 支持: # CHANGELOG, # :memo: CHANGELOG, # Changelog 等
|
||||
|
||||
# 尝试找到 CHANGELOG 标题(不区分大小写,可选 emoji)
|
||||
header_pattern = r'^#\s*(?::[\w_]+:)?\s*CHANGELOG\s*\n'
|
||||
match = re.search(header_pattern, existing_content, re.IGNORECASE | re.MULTILINE)
|
||||
|
||||
if match:
|
||||
# 找到了 CHANGELOG 标题,在其后插入
|
||||
insert_pos = match.end()
|
||||
# 确保标题后有空行
|
||||
if not existing_content[insert_pos:insert_pos+1] == '\n':
|
||||
new_content = existing_content[:insert_pos] + '\n' + changelog_content + existing_content[insert_pos:]
|
||||
else:
|
||||
new_content = existing_content[:insert_pos] + '\n' + changelog_content + existing_content[insert_pos+1:]
|
||||
else:
|
||||
# 没有找到 CHANGELOG 标题,在文件开头插入标题和内容
|
||||
if existing_content.strip():
|
||||
# 文件有内容但没有 CHANGELOG 标题
|
||||
new_content = f"# :memo: CHANGELOG\n\n{changelog_content}{existing_content}"
|
||||
else:
|
||||
# 文件为空
|
||||
new_content = f"# :memo: CHANGELOG\n\n{changelog_content}"
|
||||
|
||||
# 检查内容是否真的改变
|
||||
content_changed = (new_content != existing_content)
|
||||
|
|
|
|||
Loading…
Reference in New Issue