fix: resolve AstrBot runtime version from package metadata#143
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces support for resolving the AstrBot runtime version when it is dynamically assigned from the package's version in astrbot/init.py rather than being a static string. It also updates the test suite to cover this new behavior. The feedback suggests enhancing the regular expression used to detect this assignment so that it optionally supports the astrbot. prefix (e.g., VERSION = astrbot.version), ensuring robust matching.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| const content = await readFile(defaultConfigPath, 'utf8'); | ||
| const match = /^\s*VERSION\s*=\s*["']([^"']+)["']\s*(?:#.*)?$/m.exec(content); | ||
| if (!match) { | ||
| if (/^\s*VERSION\s*=\s*__version__\s*(?:#.*)?$/m.test(content)) { |
There was a problem hiding this comment.
The PR description mentions supporting cases where default.py assigns VERSION from astrbot.__version__. However, the current regular expression only matches __version__ directly. To fully support both VERSION = __version__ and VERSION = astrbot.__version__ as described, we should make the astrbot. prefix optional in the regex.
| if (/^\s*VERSION\s*=\s*__version__\s*(?:#.*)?$/m.test(content)) { | |
| if (/^\s*VERSION\s*=\s*(?:astrbot\.)?__version__\s*(?:#.*)?$/m.test(content)) { |
Summary
Why
The Build Desktop Tauri workflow now reaches prepare:resources for v4.26.1, but AstrBot v4.26.1 uses VERSION = version in astrbot/core/config/default.py. The existing parser only accepted quoted static VERSION values and failed before resource builds.
Validation
Co-Authored-By: Warp agent@warp.dev
Summary by Sourcery
Improve AstrBot runtime version resolution to support both static VERSION definitions and versions sourced from the package metadata.
Bug Fixes:
Tests: