refactor: centralize GitHub API logic and add check-version command#2987
refactor: centralize GitHub API logic and add check-version command#2987ProdByBuddha wants to merge 3 commits intofreenet:mainfrom
Conversation
cbae14d to
584780f
Compare
This refactor extracts the GitHub release fetching logic into a shared `commands::utils` module, reducing duplication across `update`, `auto-update`, and the new `check-version` commands. Key changes: - Centralized `get_latest_release` in `utils.rs` with a 10s timeout. - Added `freenet check-version` command for manual update checks. - Fixed a bug in `update.rs` where `$?` was incorrectly escaped in the service wrapper update check. - Added unit tests for version comparison.
584780f to
971d392
Compare
There was a problem hiding this comment.
Copilot wasn't able to review any files in this pull request.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
🔍 Rule Review: centralize GitHub API logic + check-version commandRules checked: CriticalNone. WarningsNone. Info
Automated review against |
|
Thanks for the contribution! The deduplication of GitHub API logic between However, both files have been heavily modified since this PR was opened (auto-update restart loop fixes, dirty build detection, range-based version compatibility, etc.), so this PR now has significant merge conflicts and would need to be essentially rewritten to rebase on current main. Closing for now — if we want to revisit the deduplication it'll be easier to do fresh from the current codebase. [AI-assisted - Claude] |
Problem
GitHub API fetching logic was duplicated across
update.rsandauto_update.rs. Additionally, a bug in a previous refactoring attempt (due to shell interpolation) corrupted the$?variable in the macOS service wrapper update detection, making it always appear as\0. Finally, there was no way for users to manually check for updates without starting the update process.Solution
commands::utilsmodule.ReleaseandAssetstructs and added a 10s timeout toreqwestcalls for better resilience.check-versioncommand.$?in the macOS service wrapper update check.Testing
check_version.rsto verify semver comparison logic.cargo clippyandcargo fmtpass in Codespace.$?in the generatedupdate.rs.Fixes #2962