HibiKier / zhenxun_bot

基于 Nonebot2 开发,非常可爱的绪山真寻bot
GNU Affero General Public License v3.0
3.36k stars 605 forks source link

:hammer: 提取GitHub相关操作 #1609

Closed AkashiCoin closed 2 months ago

AkashiCoin commented 2 months ago

Summary by Sourcery

将与 GitHub 相关的操作重构到一个专用的实用程序模块中,增强模块化和可重用性。更新自动更新和 Web UI 资产管理流程以使用新的实用程序函数,提高一致性和可维护性。调整测试以符合重构后的代码。

增强功能:

测试:

Original summary in English ## Summary by Sourcery Refactor GitHub-related operations into a dedicated utility module, enhancing modularity and reusability. Update the auto-update and web UI asset management processes to use the new utility functions, improving consistency and maintainability. Adjust tests to align with the refactored code. Enhancements: - Refactor GitHub-related operations into a separate utility module for better modularity and reusability. - Improve the update mechanism by using a unified method to fetch version information and download URLs from GitHub. - Enhance the web UI asset management by dynamically determining folders to mount and improving logging. - Simplify the configuration by removing hardcoded GitHub URLs and patterns, and using a default GitHub URL. Tests: - Update tests to reflect changes in GitHub URL handling and ensure compatibility with the new utility functions.
sourcery-ai[bot] commented 2 months ago

审核指南由 Sourcery 提供

此拉取请求将与 GitHub 相关的操作重构到一个单独的实用程序模块中,更新了自动更新和插件商店功能以使用新的实用程序,并对 WebUI 资产管理进行了一些调整。更改旨在改善代码组织、可重用性和可维护性。

文件级更改

更改 详情 文件
将与 GitHub 相关的操作提取到一个新的实用程序模块中
  • 为 GitHub 实用程序创建了新文件:models.py, func.py, consts.py 和 init.py
  • 实现了用于处理存储库信息的 RepoInfo 类
  • 添加了用于获取不同 GitHub 资源的最快下载 URL 的函数
  • 将与 GitHub 操作相关的常量和模式移动到 consts.py
zhenxun/utils/github_utils/models.py
zhenxun/utils/github_utils/func.py
zhenxun/utils/github_utils/consts.py
zhenxun/utils/github_utils/__init__.py
更新自动更新功能以使用新的 GitHub 实用程序
  • 使用 RepoInfo 替换硬编码的 URL 以动态生成 URL
  • 更新版本获取逻辑以使用新的 GitHub 实用程序
  • 通过使用新的实用程序函数简化更新过程
zhenxun/builtin_plugins/auto_update/_data_source.py
zhenxun/builtin_plugins/auto_update/config.py
重构插件商店以使用新的 GitHub 实用程序
  • 更新插件安装过程以使用 RepoInfo 进行 URL 生成
  • 删除与 GitHub 操作相关的冗余代码
  • 简化获取插件信息和文件的过程
zhenxun/builtin_plugins/plugin_store/data_source.py
zhenxun/builtin_plugins/plugin_store/config.py
更新 WebUI 资产管理
  • 将 WebUI 相关的常量移动到配置文件中
  • 更新资产下载过程以使用新的 GitHub 实用程序
  • 改进 WebUI 初始化过程中的错误处理和日志记录
zhenxun/builtin_plugins/web_ui/public/__init__.py
zhenxun/builtin_plugins/web_ui/public/data_source.py
zhenxun/builtin_plugins/web_ui/config.py
更新测试以适应新的 GitHub 实用程序
  • 为新的 GitHub 实用程序函数添加了模拟的 API 调用
  • 更新测试用例以使用新的 RepoInfo 类和实用程序函数
tests/builtin_plugins/auto_update/test_check_update.py

提示 - 通过在拉取请求上评论 `@sourcery-ai review` 来触发新的 Sourcery 审核。 - 通过直接回复审核评论继续与 Sourcery 的讨论。 - 您可以随时通过访问您的[仪表板](https://app.sourcery.ai)更改您的审核设置: - 启用或禁用 Sourcery 生成的拉取请求摘要或审核指南; - 更改审核语言; - 如果您有任何问题或反馈,您可以随时[联系我们](mailto:support@sourcery.ai)。
Original review guide in English ## Reviewer's Guide by Sourcery This pull request refactors GitHub-related operations into a separate utility module, updates the auto-update and plugin store functionalities to use the new utility, and makes some adjustments to the WebUI asset management. The changes aim to improve code organization, reusability, and maintainability. ### File-Level Changes | Change | Details | Files | | ------ | ------- | ----- | | Extracted GitHub-related operations into a new utility module |
  • Created new files for GitHub utilities: models.py, func.py, consts.py, and __init__.py
  • Implemented RepoInfo class for handling repository information
  • Added functions for getting fastest download URLs for different GitHub resources
  • Moved constants and patterns related to GitHub operations to consts.py
| `zhenxun/utils/github_utils/models.py`
`zhenxun/utils/github_utils/func.py`
`zhenxun/utils/github_utils/consts.py`
`zhenxun/utils/github_utils/__init__.py` | | Updated auto-update functionality to use the new GitHub utilities |
  • Replaced hardcoded URLs with dynamic URL generation using RepoInfo
  • Updated version fetching logic to use the new GitHub utilities
  • Simplified the update process by using the new utility functions
| `zhenxun/builtin_plugins/auto_update/_data_source.py`
`zhenxun/builtin_plugins/auto_update/config.py` | | Refactored plugin store to use the new GitHub utilities |
  • Updated plugin installation process to use RepoInfo for URL generation
  • Removed redundant code related to GitHub operations
  • Simplified the process of fetching plugin information and files
| `zhenxun/builtin_plugins/plugin_store/data_source.py`
`zhenxun/builtin_plugins/plugin_store/config.py` | | Updated WebUI asset management |
  • Moved WebUI-related constants to the config file
  • Updated the asset download process to use the new GitHub utilities
  • Improved error handling and logging in the WebUI initialization process
| `zhenxun/builtin_plugins/web_ui/public/__init__.py`
`zhenxun/builtin_plugins/web_ui/public/data_source.py`
`zhenxun/builtin_plugins/web_ui/config.py` | | Updated tests to accommodate the new GitHub utilities |
  • Added mocked API calls for the new GitHub utility functions
  • Updated test cases to use the new RepoInfo class and utility functions
| `tests/builtin_plugins/auto_update/test_check_update.py` | ---
Tips - Trigger a new Sourcery review by commenting `@sourcery-ai review` on the pull request. - Continue your discussion with Sourcery by replying directly to review comments. - You can change your review settings at any time by accessing your [dashboard](https://app.sourcery.ai): - Enable or disable the Sourcery-generated pull request summary or reviewer's guide; - Change the review language; - You can always [contact us](mailto:support@sourcery.ai) if you have any questions or feedback.