fix(release): update CHANGELOG bottom comparison links on release#50
fix(release): update CHANGELOG bottom comparison links on release#50ThirteenLLB merged 3 commits intomainfrom
Conversation
The update-changelog.py script previously only replaced the [Unreleased] heading but did not maintain the bottom comparison links per Keep a Changelog spec. Now it updates/creates [Unreleased] and version compare links automatically when --repo is provided. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Walkthrough为发布工作流和变更日志脚本增加对仓库名的传递与处理:工作流在两处调用 Changes
Sequence Diagram(s)(本次改动为参数传递与文件内链路生成,控制流简单,故不生成序列图) 代码审查工作量评估🎯 2 (Simple) | ⏱️ ~15 minutes 可能相关的拉取请求
建议的审阅者
诗句
✅ Pre-merge checks override appliedThe pre-merge checks have been overridden successfully. You can now proceed with the merge. Overridden by ❌ Failed checks (3 errors)
✅ Passed checks (4 passed)
✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
scripts/update-changelog.py (1)
14-21: 如需支持完整 SemVer,这里的版本提取还不够宽。Line 17 现在只覆盖
x.y.z和单段-suffix。像1.2.3-alpha-beta、1.2.3+build.1这类合法版本标题不会被识别,Line 94 就会拿不到prev_version,把连续发布误判成首发版链接。若这些仓库后续可能发预发布版,建议把匹配放宽,或直接复用现成的版本解析规则。可参考的修正方向
- versions = re.findall(r'## \[(\d+\.\d+\.\d+(?:-[a-zA-Z0-9.]+)?)\]', content) + versions = re.findall( + r'## \[((?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)' + r'(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?' + r'(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?)\]', + content, + )Also applies to: 94-95
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@scripts/update-changelog.py` around lines 14 - 21, The current version-extraction regex in _find_previous_version is too narrow and misses full SemVer strings (prerelease with multiple hyphen segments and build metadata), causing prev_version to be None later (see usage around prev_version handling at lines ~94-95); update the function to either use a robust SemVer parser (e.g., python-semver or packaging.version) to parse headers or expand the regex to capture full SemVer including optional prerelease and build metadata (e.g., allow multiple hyphen-separated identifiers and optional +build metadata) so that versions like 1.2.3-alpha-beta and 1.2.3+build.1 are recognized by _find_previous_version. Ensure the returned version string matches what the later code expects.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/centralized-release.yml:
- Around line 103-107: 在调用 update-changelog.py 时将 matrix.version 和 matrix.repo
用双引号包裹,避免单词拆分和特殊字符破坏命令;具体地,修改包含 symbols matrix.version 和 matrix.repo 的两个调用位置(即传递
--version 和 --repo 的参数处),把 ${ matrix.version } 和 ${ matrix.repo } 改为 "${{
matrix.version }}" 和 "${{ matrix.repo }}"(保持与已引号的 $CHANGELOG_PATH
等变量一致),并在两个调用点同时应用相同修改以保持一致性。
---
Nitpick comments:
In `@scripts/update-changelog.py`:
- Around line 14-21: The current version-extraction regex in
_find_previous_version is too narrow and misses full SemVer strings (prerelease
with multiple hyphen segments and build metadata), causing prev_version to be
None later (see usage around prev_version handling at lines ~94-95); update the
function to either use a robust SemVer parser (e.g., python-semver or
packaging.version) to parse headers or expand the regex to capture full SemVer
including optional prerelease and build metadata (e.g., allow multiple
hyphen-separated identifiers and optional +build metadata) so that versions like
1.2.3-alpha-beta and 1.2.3+build.1 are recognized by _find_previous_version.
Ensure the returned version string matches what the later code expects.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 0f90ece7-8a2d-4590-add7-10b3df66bc3e
📒 Files selected for processing (2)
.github/workflows/centralized-release.ymlscripts/update-changelog.py
Strip -dev/-private suffix from repo name when generating comparison links for public CHANGELOG, so links point to the public repository. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
♻️ Duplicate comments (1)
.github/workflows/centralized-release.yml (1)
103-107:⚠️ Potential issue | 🟠 Major给
--version/--repo参数补上双引号。Line 105、Line 106、Line 132 和 Line 133 这两处调用仍然把来自
workflow_dispatch输入的值直接拼进 shell。这样会有单词拆分和参数串改风险,和同一步里已加引号的路径变量也不一致。建议修改
python3 ../.github-repo/scripts/update-changelog.py \ --file "$CHANGELOG_PATH" \ - --version ${{ matrix.version }} \ - --repo ${{ matrix.repo }} \ + --version "${{ matrix.version }}" \ + --repo "${{ matrix.repo }}" \ $date_arg @@ python3 ../.github-repo/scripts/update-changelog.py \ --file "$PUBLIC_CHANGELOG_PATH" \ - --version ${{ matrix.version }} \ + --version "${{ matrix.version }}" \ --repo "$PUBLIC_REPO" \ $date_argAlso applies to: 130-134
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/centralized-release.yml around lines 103 - 107, The shell invocation of the changelog updater passes unquoted workflow inputs to the --version and --repo flags; update the two calls to python3 ../.github-repo/scripts/update-changelog.py so that the --version and --repo arguments are wrapped in double quotes (e.g., --version "${{ matrix.version }}" and --repo "${{ matrix.repo }}") for both occurrences (the earlier call and the later duplicate call), ensuring consistent quoting to prevent word-splitting and argument injection when invoking update-changelog.py.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In @.github/workflows/centralized-release.yml:
- Around line 103-107: The shell invocation of the changelog updater passes
unquoted workflow inputs to the --version and --repo flags; update the two calls
to python3 ../.github-repo/scripts/update-changelog.py so that the --version and
--repo arguments are wrapped in double quotes (e.g., --version "${{
matrix.version }}" and --repo "${{ matrix.repo }}") for both occurrences (the
earlier call and the later duplicate call), ensuring consistent quoting to
prevent word-splitting and argument injection when invoking update-changelog.py.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7e7688bb-77dd-40f0-ab5c-b9a9678f328e
📒 Files selected for processing (1)
.github/workflows/centralized-release.yml
- Quote matrix.version and matrix.repo in workflow shell commands to prevent word splitting - Widen version regex to match full SemVer: multi-segment prerelease (1.2.3-alpha-beta) and build metadata (1.0.0+build.1) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
scripts/update-changelog.py (1)
94-94: 考虑拆分复杂的单行表达式以提高可读性。该行将 walrus 运算符 (
:=) 与三元表达式组合在一起,且超出了常规行长度限制,影响可读性。建议拆分为多个语句。♻️ 建议的重构
- new_unreleased_link = f"[Unreleased]: {base_url}/compare/v{version}...HEAD" - new_version_link = f"[{version}]: {base_url}/compare/v{prev_version}...v{version}" if (prev_version := _find_previous_version(content_new, version)) else f"[{version}]: {base_url}/releases/tag/v{version}" + new_unreleased_link = f"[Unreleased]: {base_url}/compare/v{version}...HEAD" + prev_version = _find_previous_version(content_new, version) + if prev_version: + new_version_link = f"[{version}]: {base_url}/compare/v{prev_version}...v{version}" + else: + new_version_link = f"[{version}]: {base_url}/releases/tag/v{version}"🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@scripts/update-changelog.py` at line 94, 该行将复杂的三元表达式和 walrus 运算符混在一起,降低可读性:把表达式拆成多个语句,先调用 _find_previous_version(content_new, version) 并将结果赋给局部变量 prev_version,然后根据 prev_version 是否为真分别构建 new_version_link(使用 base_url、prev_version、version),以替代当前在 new_version_link 中直接嵌套 walrus 和三元表达式;确保变量名为 prev_version,保留原有字符串格式和 f-string 插值逻辑。
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@scripts/update-changelog.py`:
- Line 94: 该行将复杂的三元表达式和 walrus 运算符混在一起,降低可读性:把表达式拆成多个语句,先调用
_find_previous_version(content_new, version) 并将结果赋给局部变量 prev_version,然后根据
prev_version 是否为真分别构建 new_version_link(使用 base_url、prev_version、version),以替代当前在
new_version_link 中直接嵌套 walrus 和三元表达式;确保变量名为 prev_version,保留原有字符串格式和 f-string
插值逻辑。
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: cd32f88a-d88e-4e3f-8a4f-d7044eda5cdb
📒 Files selected for processing (2)
.github/workflows/centralized-release.ymlscripts/update-changelog.py
🚧 Files skipped from review as they are similar to previous changes (1)
- .github/workflows/centralized-release.yml
Summary
update-changelog.py新增--repo参数,发版时自动维护 CHANGELOG 底部的比较链接compare/vOLD...vNEW,首次发版生成releases/tag/vX.Y.Zcentralized-release.yml两处调用均传入--repo--repo则行为不变Test plan
releases/tag格式链接--repo:不生成链接(向后兼容)🤖 Generated with Claude Code
Summary by CodeRabbit