Fix README version replacement bug and improve mirror script robustness#2
Closed
Fix README version replacement bug and improve mirror script robustness#2
Conversation
Copilot
AI
changed the title
[WIP] 当前 repo 的工作流程是,
Fix README version replacement bug and improve mirror script robustness
Sep 4, 2025
mirror.yml 定时抓取上游 PyPI 新版本,依此打 tag 发版,release.yml 则会在打 tag 时自动发布到 GitHub releases
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The original
mirror.pyscript had a critical bug in the README version replacement logic that could cause incorrect version updates and potential workflow failures.Critical Bug: Substring Replacement Issue
The original code used simple string replacement:
This caused problems when version numbers were substrings of each other:
1.36.1with1.36.2in README containingv1.36.10would incorrectly producev1.36.20Additional Issues
Solution
1. Fixed README Version Replacement
Replaced naive string replacement with precise regex targeting:
This ensures only the
rev: v{version}line in YAML configuration is updated, preventing partial matches.2. Added Git Tag Conflict Resolution
3. Enhanced Error Handling and Logging
check=Trueto all git operations for proper error detection4. Fixed Multi-Version Processing
Ensured the
readmevariable is updated after each version so subsequent updates work correctly.Testing
Created comprehensive validation that verifies:
Impact
This fix ensures the automated typos version mirroring workflow runs reliably:
The workflow now correctly implements the requirements:
mirror.ymlperiodically fetches new upstream PyPI versions, creates appropriate tags, andrelease.ymlautomatically publishes GitHub releases.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
astral.shcurl -LsSf REDACTED(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.