Skip to content

fix(release): update CHANGELOG bottom comparison links on release#50

Merged
ThirteenLLB merged 3 commits intomainfrom
fix/changelog-comparison-links
Mar 10, 2026
Merged

fix(release): update CHANGELOG bottom comparison links on release#50
ThirteenLLB merged 3 commits intomainfrom
fix/changelog-comparison-links

Conversation

@ThirteenLLB
Copy link
Contributor

@ThirteenLLB ThirteenLLB commented Mar 10, 2026

Summary

  • update-changelog.py 新增 --repo 参数,发版时自动维护 CHANGELOG 底部的比较链接
  • 有上一版本时生成 compare/vOLD...vNEW,首次发版生成 releases/tag/vX.Y.Z
  • centralized-release.yml 两处调用均传入 --repo
  • 向后兼容:不传 --repo 则行为不变

Test plan

  • 有历史版本 + 已有链接:链接正确更新
  • 首次发版无链接:追加 releases/tag 格式链接
  • 不传 --repo:不生成链接(向后兼容)
  • 首次发版但有 Unreleased 链接:正确替换
  • 连续多版本:链接链完整保留

🤖 Generated with Claude Code

Summary by CodeRabbit

  • 改进
    • 变更日志生成流程现在支持基于目标仓库生成公开版本的更新,发布时会在底部添加更准确的版本比较链接,提升历史可追溯性。
    • 发布步骤对仓库名称和版本参数的传递与引用进行了统一处理,确保公开 changelog 更新时版本和目标仓库信息一致且稳健。

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>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 10, 2026

Walkthrough

为发布工作流和变更日志脚本增加对仓库名的传递与处理:工作流在两处调用 scripts/update-changelog.py 时传入派生的公共仓库名(去除 -dev/-private 后缀),脚本新增 repo 参数与 _find_previous_version(),并基于仓库生成底部版本比较链接以更新 Unreleased 部分(保持日期逻辑不变)。

Changes

Cohort / File(s) Summary
工作流程配置
\.github/workflows/centralized-release.yml
在两处调用 scripts/update-changelog.py 时新增 --repo 参数并传入由 REPO_NAME 派生的 PUBLIC_REPO(去除 -dev/-private 后缀);对版本参数增加引号,保持日期处理不变。
变更日志脚本增强
scripts/update-changelog.py
新增辅助函数 \_find_previous_version(content, current_version);扩展 update_changelog(file_path, version, release_date=None, repo=None) 接口以支持 repo,并基于 repo 构建仓库专用比较链接,更新或追加底部的 Unreleased 与新版本链接;CLI 增加 --repo 参数并转发。

Sequence Diagram(s)

(本次改动为参数传递与文件内链路生成,控制流简单,故不生成序列图)

代码审查工作量评估

🎯 2 (Simple) | ⏱️ ~15 minutes

可能相关的拉取请求

建议的审阅者

  • chenjunnn
  • yuanyuanxin

诗句

🐰
把仓库名从尾巴剥出,
链接跳跃找回头,
Unreleased 换上新装,
小兔敲键记版本,
草地一角庆功舞!


✅ Pre-merge checks override applied

The pre-merge checks have been overridden successfully. You can now proceed with the merge.

Overridden by @ThirteenLLB via checkbox on 2026-03-10T11:16:31.265Z.

❌ Failed checks (3 errors)

Check name Status Explanation Resolution
Changelog ❌ Error [IGNORED] 该PR包含代码更改(scripts/update-changelog.py增加38行),但不涉及用户可见功能变更。根据规则,代码更改需更新CHANGELOG.md,但原始摘要未显示任何CHANGELOG文件被修改。 请在CHANGELOG.md中添加此PR的更改摘要,记录scripts/update-changelog.py的新增--repo参数和工作流更新。
Pr Description ❌ Error [IGNORED] PR描述缺少飞书工作项ID引用(m-或f-格式)。 请在PR描述中添加飞书工作项ID引用,格式为m-或f-(例如m-123)。
Branch Name ❌ Error [IGNORED] 源分支名称 fix/changelog-comparison-links 不符合要求的命名规范 fix/f-<number>/<description>,缺少必需的 f-<number> 标识符。 请将分支重命名为 fix/f-<issue-number>/changelog-comparison-links 的格式,其中 <issue-number> 是对应的问题编号。
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题完全遵循Conventional Commits规范,类型为'fix',作用域为'release',主题具体明确地描述了更新CHANGELOG底部比较链接的核心变更。
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Design Docs ✅ Passed PR中的改变涉及CI/CD工作流配置和脚本参数扩展,满足文档检查的跳过条件(docs/internal/design/和docs/internal/architecture/目录不存在)
✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/changelog-comparison-links

Comment @coderabbitai help to get the list of available commands and usage tips.

@ThirteenLLB ThirteenLLB requested a review from chenjunnn March 10, 2026 11:02
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-beta1.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

📥 Commits

Reviewing files that changed from the base of the PR and between 1c25c7b and c85eaf7.

📒 Files selected for processing (2)
  • .github/workflows/centralized-release.yml
  • scripts/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>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ 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_arg

Also 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

📥 Commits

Reviewing files that changed from the base of the PR and between c85eaf7 and b641534.

📒 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>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 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

📥 Commits

Reviewing files that changed from the base of the PR and between b641534 and dd99ce1.

📒 Files selected for processing (2)
  • .github/workflows/centralized-release.yml
  • scripts/update-changelog.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/centralized-release.yml

@ThirteenLLB ThirteenLLB merged commit fcca135 into main Mar 10, 2026
1 check passed
@ThirteenLLB ThirteenLLB deleted the fix/changelog-comparison-links branch March 10, 2026 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants