StarRailOneDragon
StarRailOneDragon copied to clipboard
feat: 内置pygit2进行代码管理
Summary by CodeRabbit
发布说明
-
新功能
- 代码设置中新增自动更新选项。
-
功能移除
- 从安装程序中移除 Git 环境安装步骤。
-
优化
- 更新 Git 远程配置机制。
- 修复分页计算逻辑。
-
依赖
- 添加 pygit2 依赖库。
Walkthrough
本次更新将 Git 功能从调用系统 Git 重构为基于 pygit2 的实现,移除 DownloadService 依赖,新增多个仓库管理与查询接口,并同步更新依赖、安装器与若干设置/界面中关于 Git 的组件与选项。
Changes
| Cohort / File(s) | 变更摘要 |
|---|---|
构建与依赖 deploy/OneDragon-Launcher.spec, pyproject.toml |
在 PyInstaller 隐藏导入中加入 _cffi_backend;在依赖中新增 pygit2==1.19.0 |
环境配置 src/one_dragon/envs/env_config.py |
移除 DEFAULT_GIT_DIR_PATH、DEFAULT_GIT_PATH 与 GitMethodEnum;新增 GitRemoteEnum;将 git_method 属性替换为 git_remote;修改 ocr_cache 的保存行为 |
Git 服务重构(核心) src/one_dragon/envs/git_service.py |
用 pygit2 完全重写 GitService:移除 download_service 参数,添加 repo_dir 参数;新增 GitLog;实现仓库打开/克隆、远程确保、fetch、reset、checkout、分支与提交遍历、标签计算、版本查询等一系列公开方法与内部辅助函数;支持代理与进度回调 |
依赖注入调整 src/one_dragon/base/operation/one_dragon_env_context.py |
更新 GitService 的构造调用,去除传入的 download_service 参数 |
UI — 安装器 src/one_dragon_qt/view/installer_interface.py, src/one_dragon_qt/widgets/install_card/git_install_card.py |
删除 GitInstallCard 文件与组件;从基础安装卡片和高级安装步骤中移除 Git 环境步骤,调整安装步骤顺序 |
UI — 代码与设置界面 src/one_dragon_qt/view/code_interface.py, src/one_dragon_qt/view/setting/setting_env_interface.py |
移除 Git 安装/显示卡片,新增 auto_update_opt(SwitchSettingCard)替代原有 git_method 选项;调整页码计算公式;删除与 Git proxy 初始化/重置相关的调用 |
UI — 源配置 src/one_dragon_qt/view/source_config_interface.py |
将 update_git_remote() 替换为 update_remote();移除自动触发的 GH proxy 更新与早期代理初始化重置调用 |
Sequence Diagram(s)
sequenceDiagram
participant UI as UI 层
participant EnvCtx as EnvContext
participant GitSvc as GitService
participant PyGit2 as pygit2
participant Remote as 远程仓库
Note over GitSvc,PyGit2: 新的 pygit2 驱动工作流
UI->>EnvCtx: 请求同步/更新代码
EnvCtx->>GitSvc: fetch_latest_code(progress_cb)
GitSvc->>GitSvc: _open_repo() / _validate_working_directory()
alt 本地仓库存在
GitSvc->>PyGit2: 打开仓库 & _ensure_remote()
GitSvc->>PyGit2: _fetch_remote()
PyGit2->>Remote: fetch
Remote-->>PyGit2: 对象
GitSvc->>GitSvc: _checkout_branch() / _sync_with_remote()
else 仓库不存在
GitSvc->>PyGit2: _clone_repository(progress_cb)
PyGit2->>Remote: clone
Remote-->>PyGit2: 完整仓库
end
GitSvc-->>EnvCtx: (success:boolean, message:str)
EnvCtx-->>UI: 同步结果显示
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~60 minutes
- 重点关注:
src/one_dragon/envs/git_service.py:pygit2 API 使用、错误处理、代理配置与进度回调的正确性与边界情况src/one_dragon/envs/env_config.py:配置字段与枚举变更对其他模块的兼容性src/one_dragon/base/operation/one_dragon_env_context.py:GitService 构造签名变更的所有调用点- UI 变更文件 (
code_interface.py,setting_env_interface.py,installer_interface.py):移除 Git 组件后界面逻辑是否仍然一致、页码计算和选项绑定是否正确
Poem
🐰 我在树下轻敲键,铺上新枝与路径,
旧命令化作风,新的 pygit2 跳跃径直,
克隆分支与标签,进度灯闪着星,
小兔为代码鼓掌,仓库路更清明。
Pre-merge checks and finishing touches
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 76.47% which is insufficient. The required threshold is 80.00%. | You can run @coderabbitai generate docstrings to improve docstring coverage. |
✅ Passed checks (2 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | 拉取请求标题准确总结了主要变更:引入pygit2库用于代码管理。标题清晰简洁,反映了整个变更集的核心目的。 |
✨ Finishing touches
- [ ] 📝 Generate docstrings
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.