Fix file deletion and version parsing in upgrade.py; resolve related test issue
Contributor Checklist
- [x] Pull request is made from a separate branch, not the main branch
- [x] Code has been tested using
pytestas explained in the contributing guide - [x] I agree to follow Scribe-Data's Code of Conduct
Description
Improved File Safety During Upgrade
- Prevents deletion of important folders like
venv,.venv, and user files. - Introduces
MANAGED_DIRSandMANAGED_FILESto specify which files should be updated (e.g.,scribe_data/,setup.py). - Adds
EXCLUDE_DIRSto skip folders like.gitand virtual environments. - Ensures only Scribe-managed files are updated while preserving everything else.
Fixed Version Parsing to Prevent 404 Errors
- Replaces version strings like
"Scribe-Data 4.1.0"with just the number using regex (e.g.,4.1.0). - Builds the correct GitHub tag URL (e.g.,
v4.1.0) to avoid broken links during download.
Testing
-
Ran
scribe-data --upgradewhen current version is4.1.0
✅ "You already have the latest version of Scribe-Data: 4.1.0" -
Mocked a newer version (
4.2.0) → Confirmed:
✅venvand user files were preserved
✅ Managed files were updated properly -
🔧 Added Unit tests using
pytest.
Related Issue
Fixes #596
Thank you for the pull request! ❤️
The Scribe-Data team will do our best to address your contribution as soon as we can. If you're not already a member of our public Matrix community, please consider joining! We'd suggest using Element as your Matrix client, and definitely join the General and Data rooms once you're in. Also consider attending our bi-weekly Saturday dev syncs. It'd be great to meet you 😊
Maintainer Checklist
The following is a checklist for maintainers to make sure this process goes as well as possible. Feel free to address the points below yourself in further commits if you realize that actions are needed :)