Skip to content

feat: add release_versions and pre_release_versions config options#199

Merged
Harry-Chen merged 5 commits into
tuna:masterfrom
yaoge123:master
May 17, 2026
Merged

feat: add release_versions and pre_release_versions config options#199
Harry-Chen merged 5 commits into
tuna:masterfrom
yaoge123:master

Conversation

@yaoge123
Copy link
Copy Markdown
Contributor

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 sync
  • pre_release_versions: number of pre-releases to sync

Usage

{
    "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

  • Original versions field remains unchanged (mixed sorting mode)
  • When either new field is configured, separate limits mode is activated
  • pre_release field is auto-enabled in separate limits mode

Example scenarios

Config Result
{"repo": "x"} Latest 1 stable release (default)
{"repo": "x", "release_versions": 1, "pre_release_versions": 1} 1 stable + 1 pre-release
{"repo": "x", "versions": 3, "pre_release": true} Latest 3 (mixed, backward compatible)

Copilot AI review requested due to automatic review settings May 17, 2026 09:05
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds two new optional config fields, release_versions and pre_release_versions, to github-release.py so users can independently cap the number of synced stable releases and pre-releases. When either field is set, a new "separate limits" mode is activated (auto-enabling pre-release inclusion); otherwise the legacy versions + pre_release behavior is intended to remain.

Changes:

  • Parse new release_versions / pre_release_versions config fields and derive max_release / max_prerelease / mode flag.
  • Track separate counters (n_release, n_prerelease) and add per-kind limit checks inside the release loop.
  • Replace the single versions-based break condition with a dual release_done / prerelease_done termination check.
Comments suppressed due to low confidence (1)

github-release.py:307

  • The limit-checking block (lines 293–307) is unnecessarily convoluted and contains dead/overlapping branches. For example, when max_prerelease == 0 and the release is a pre-release, the code falls through branch 1, branch 2, branch 3 (when max_release > 0), into the else at line 302, where line 304 again checks the same condition. The elif max_release <= 0 and max_prerelease <= 0 "unlimited" pass and the final else mixed-mode handler effectively re-encode what the first two branches were trying to express.

This logic can be simplified to two straightforward checks (per-kind cap when cap > 0, otherwise skip if cap == 0 and use_separate_limits is in effect, otherwise unlimited) and would be far easier to reason about. As-is, the control flow makes it easy to introduce regressions like the legacy-mode pre-release filtering issue noted separately.

                # Check version limits
                if is_prerelease and max_prerelease > 0:
                    if n_prerelease >= max_prerelease:
                        continue
                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

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread github-release.py Outdated
Comment on lines +293 to +332
# 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:
break
yaoge123 added 3 commits May 17, 2026 17:10
In legacy mode (use_separate_limits=False), use the single n_downloaded
counter against versions for all releases. The separate max_prerelease=0
was incorrectly skipping pre-releases in legacy mode when pre_release=True.
When a limit is -1, the skip check should never trigger and the done
check should never be satisfied, allowing unlimited syncing for that
category.
@yaoge123
Copy link
Copy Markdown
Contributor Author

Follow-up on the Copilot review: the review was against ace7973, while the current PR HEAD is 9383fa6.

The latest code addresses the review feedback and subsequent edge cases by separating the two behaviors explicitly:

  • Legacy mode preserves the original versions + pre_release behavior, using one mixed n_downloaded counter.
  • Separate-limits mode uses independent release_versions and pre_release_versions counters.
  • 0 means that category is skipped.
  • -1 means unlimited and does not satisfy the done condition prematurely.

So the old convoluted limit-checking block has been replaced, and the legacy mixed pre-release behavior is preserved in the current HEAD.

@Harry-Chen Harry-Chen merged commit 93b8cff into tuna:master May 17, 2026
13 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants