feat: add release_versions and pre_release_versions config options#198
Closed
yaoge123 wants to merge 2 commits into
Closed
feat: add release_versions and pre_release_versions config options#198yaoge123 wants to merge 2 commits into
yaoge123 wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds configuration support to control how many stable releases vs pre-releases are synced from GitHub Releases, extending the existing versions/pre_release behavior.
Changes:
- Introduces
release_versionsandpre_release_versionsconfig fields and a “separate limits” mode when either is present. - Refactors the release iteration logic to track stable vs pre-release counts independently and stop when configured limits are reached.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| prerelease = True | ||
| else: | ||
| max_release = versions | ||
| max_prerelease = 0 |
Comment on lines
+293
to
+331
| # Check version limits | ||
| if is_prerelease and max_prerelease > 0: | ||
| if n_prerelease >= max_prerelease: | ||
| continue | ||
| total_size += process_release( | ||
| release, | ||
| (repo_dir if flat else repo_dir / name), | ||
| tarball, | ||
| exclude_regexes, | ||
| ) | ||
| if n_downloaded == 0 and not flat: | ||
| # create a symbolic link to the latest release folder | ||
| link_latest(name, repo_dir) | ||
| n_downloaded += 1 | ||
| if versions > 0 and n_downloaded >= versions: | ||
| break | ||
| elif not is_prerelease and max_release > 0: | ||
| if n_release >= max_release: | ||
| continue | ||
| elif max_release <= 0 and max_prerelease <= 0: | ||
| pass # unlimited | ||
| else: | ||
| # Mixed mode: skip if respective limit reached | ||
| if is_prerelease and max_prerelease <= 0: | ||
| continue | ||
| if not is_prerelease and max_release <= 0: | ||
| continue | ||
|
|
||
| name = ensure_safe_name(release["name"] or release["tag_name"]) | ||
| if len(name) == 0: | ||
| logger.error("Unnamed release") | ||
| continue | ||
| total_size += process_release( | ||
| release, | ||
| (repo_dir if flat else repo_dir / name), | ||
| tarball, | ||
| exclude_regexes, | ||
| ) | ||
| if n_downloaded == 0 and not flat: | ||
| # create a symbolic link to the latest release folder | ||
| link_latest(name, repo_dir) | ||
| n_downloaded += 1 | ||
| if is_prerelease: | ||
| n_prerelease += 1 | ||
| else: | ||
| n_release += 1 | ||
|
|
||
| # Check if both limits are reached | ||
| release_done = max_release > 0 and n_release >= max_release | ||
| prerelease_done = (not prerelease) or max_prerelease <= 0 or n_prerelease >= max_prerelease | ||
| if release_done and prerelease_done: |
aa87f97 to
100630b
Compare
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.
Add support for independently controlling the number of stable releases and pre-releases to sync.
New config fields
release_versions: number of stable releases to syncpre_release_versions: number of pre-releases to syncUsage
{ "repo": "owner/repo", "release_versions": 1, "pre_release_versions": 1 }This will sync the latest 1 stable release AND the latest 1 pre-release, with independent counting.
Backward compatibility
versionsfield remains unchanged (mixed sorting mode)pre_releasefield is auto-enabled in separate limits modeExample scenarios
{"repo": "x"}{"repo": "x", "release_versions": 1, "pre_release_versions": 1}{"repo": "x", "versions": 3, "pre_release": true}