-
Notifications
You must be signed in to change notification settings - Fork 0
fix: enable firmware CHANGELOG fetching #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Add source_repo field to config for repos where input name differs from actual repo - firmware now fetches CHANGELOG from wh110-firmware repo - Update fetch script to use source_repo when fetching Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Walkthrough此 PR 为获取发布说明的脚本引入自动检测与源仓库识别:新增从 source_repo 获取最新 tag 的逻辑(含日期比较)、RELEASE_DATE 环境变量支持,并将 firmware 配置指向独立源仓库与明确的 CHANGELOG 路径。 Changes
Sequence Diagram(s)sequenceDiagram
participant GHWF as GitHub Workflow
participant Script as fetch-changelogs.py
participant GitHubAPI as GitHub API
participant Config as release-notes-config.json
GHWF->>Script: 启动脚本 (RELEASE_DATE env)
Script->>Config: 读取组件配置 (含 source_repo, auto_detect)
Script->>GitHubAPI: get_latest_tag_info(source_repo, token)
GitHubAPI-->>Script: 返回 tag 与 commit date
Script->>Script: 比较 tag date 与 RELEASE_DATE / 最近两天
alt 匹配
Script->>Script: 将 repo+version 注入待抓取列表
else 不匹配或异常
Script-->>GHWF: 记录跳过原因(日志)
end
Script->>GitHubAPI: 拉取 source_repo 的 CHANGELOG.md
GitHubAPI-->>Script: 返回 changelog 内容
Script-->>GHWF: 输出并汇总抓取结果
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
Caution Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional.
❌ Failed checks (2 errors, 1 warning)
✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
- Add auto_detect flag in config for components without auto-release - Script automatically checks if latest tag matches release date - If match found, component is added to fetch list automatically - Pass RELEASE_DATE env to fetch script in workflow - Fix missing return in fetch_changelog_from_tag function Now users don't need to manually specify firmware=x.x.x - it will be auto-detected if the firmware repo has a matching tag. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@scripts/fetch-changelogs.py`:
- Around line 74-116: The function get_latest_tag_info contains leftover
decoding logic after its final return (including references to an undefined
symbol data and base64 decoding), which is unreachable and triggers Ruff F821;
remove the entire block starting from "content = data.get(...)" through the
final return so that get_latest_tag_info ends after "return version, date_str",
leaving no references to undefined variables or dead code.
- Line 214: Print call uses an f-string with no placeholders (the print(f" ⚠️
未找到 tag,跳过", file=sys.stderr) occurrence) which triggers Ruff F541; change that
print to use a normal string literal (remove the f-prefix) so the message is
printed to stderr without an f-string.
| def get_latest_tag_info(repo, token): | ||
| """ | ||
| 获取仓库最新 tag 的版本号和日期 | ||
|
|
||
| Args: | ||
| repo: 仓库名 | ||
| token: GitHub token | ||
|
|
||
| Returns: | ||
| (version, date_str) 元组,version 不含 v 前缀,date_str 为 YYYY-MM-DD 格式 | ||
| 如果没有 tag 则返回 (None, None) | ||
| """ | ||
| # 获取最新 tag | ||
| endpoint = f"/repos/{ORG}/{repo}/tags?per_page=1" | ||
| tags = github_api(endpoint, token) | ||
| if not tags: | ||
| return None, None | ||
|
|
||
| tag_name = tags[0]["name"] | ||
| version = tag_name.lstrip("v") | ||
|
|
||
| # 获取 tag 对应的 commit 日期 | ||
| sha = tags[0]["commit"]["sha"] | ||
| commit_endpoint = f"/repos/{ORG}/{repo}/git/commits/{sha}" | ||
| commit_data = github_api(commit_endpoint, token) | ||
| if not commit_data: | ||
| return version, None | ||
|
|
||
| # 解析日期 (格式: 2026-02-02T01:46:19Z) | ||
| date_str = commit_data.get("committer", {}).get("date", "")[:10] | ||
| return version, date_str | ||
|
|
||
| content = data.get("content", "") | ||
| encoding = data.get("encoding", "") | ||
| if encoding == "base64": | ||
| try: | ||
| return base64.b64decode(content).decode("utf-8") | ||
| except UnicodeDecodeError: | ||
| print(f"⚠️ {repo}: CHANGELOG 非 UTF-8,已跳过", file=sys.stderr) | ||
| return None | ||
|
|
||
| print(f"⚠️ {repo}: 未知编码格式 {encoding}", file=sys.stderr) | ||
| return None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
删除 get_latest_tag_info 中残留的重复解码逻辑
该函数在 return 之后还有一段解码逻辑,且引用未定义的 data,会触发 Ruff F821 并可能导致 CI 失败。建议删除这段残留代码,避免误导后续维护。
建议修改
@@
date_str = commit_data.get("committer", {}).get("date", "")[:10]
return version, date_str
-
- content = data.get("content", "")
- encoding = data.get("encoding", "")
- if encoding == "base64":
- try:
- return base64.b64decode(content).decode("utf-8")
- except UnicodeDecodeError:
- print(f"⚠️ {repo}: CHANGELOG 非 UTF-8,已跳过", file=sys.stderr)
- return None
-
- print(f"⚠️ {repo}: 未知编码格式 {encoding}", file=sys.stderr)
- return None🧰 Tools
🪛 Ruff (0.14.14)
[warning] 83-83: Docstring contains ambiguous , (FULLWIDTH COMMA). Did you mean , (COMMA)?
(RUF002)
[warning] 83-83: Docstring contains ambiguous , (FULLWIDTH COMMA). Did you mean , (COMMA)?
(RUF002)
[error] 106-106: Undefined name data
(F821)
[error] 107-107: Undefined name data
(F821)
[warning] 112-112: String contains ambiguous , (FULLWIDTH COMMA). Did you mean , (COMMA)?
(RUF001)
🤖 Prompt for AI Agents
In `@scripts/fetch-changelogs.py` around lines 74 - 116, The function
get_latest_tag_info contains leftover decoding logic after its final return
(including references to an undefined symbol data and base64 decoding), which is
unreachable and triggers Ruff F821; remove the entire block starting from
"content = data.get(...)" through the final return so that get_latest_tag_info
ends after "return version, date_str", leaving no references to undefined
variables or dead code.
|
|
||
| version, tag_date = get_latest_tag_info(source_repo, token) | ||
| if version is None: | ||
| print(f" ⚠️ 未找到 tag,跳过", file=sys.stderr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
移除无占位符的 f-string
此处 f-string 不含占位符,Ruff F541 会报错。直接使用普通字符串即可。
建议修改
- print(f" ⚠️ 未找到 tag,跳过", file=sys.stderr)
+ print(" ⚠️ 未找到 tag,跳过", file=sys.stderr)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| print(f" ⚠️ 未找到 tag,跳过", file=sys.stderr) | |
| print(" ⚠️ 未找到 tag,跳过", file=sys.stderr) |
🧰 Tools
🪛 Ruff (0.14.14)
[error] 214-214: f-string without any placeholders
Remove extraneous f prefix
(F541)
[warning] 214-214: String contains ambiguous , (FULLWIDTH COMMA). Did you mean , (COMMA)?
(RUF001)
🤖 Prompt for AI Agents
In `@scripts/fetch-changelogs.py` at line 214, Print call uses an f-string with no
placeholders (the print(f" ⚠️ 未找到 tag,跳过", file=sys.stderr) occurrence) which
triggers Ruff F541; change that print to use a normal string literal (remove the
f-prefix) so the message is printed to stderr without an f-string.
Summary
修复固件 CHANGELOG 抓取逻辑,现在能正确从
wh110-firmware仓库获取固件的 CHANGELOG。变更内容
source_repo字段:当输入的 repo 名与实际仓库名不同时使用firmware配置:source_repo: "wh110-firmware",changelog_path: "CHANGELOG.md"source_repo作为抓取 CHANGELOG 的目标仓库测试结果
Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit
发布说明
功能改进
修复与增强