Skip to content

Resolve repo-prefixed version tags on checkout#293

Merged
soimkim merged 1 commit into
mainfrom
v
Jul 9, 2026
Merged

Resolve repo-prefixed version tags on checkout#293
soimkim merged 1 commit into
mainfrom
v

Conversation

@soimkim

@soimkim soimkim commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Allow -c 2.4.4 to match tags like freezed-v2.4.4 by trying repo-name-prefixed candidates and recognizing -v semver patterns in refs.

Summary by CodeRabbit

  • Bug Fixes
    • Improved checkout resolution so version and tag hints are matched more reliably against remote references.
    • Added support for version tags with common prefixes and separators, including cases like -v1.2.3 and repo-style tag names.
    • Reduced failed checkouts when the requested version is expressed in a slightly different tag format than the remote reference.

Allow -c 2.4.4 to match tags like freezed-v2.4.4 by trying repo-name-prefixed candidates and recognizing -v semver patterns in refs.
@soimkim soimkim self-assigned this Jul 9, 2026
@soimkim soimkim added the chore [PR/Issue] Refactoring, maintenance the code label Jul 9, 2026
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1266e93b-50f5-45bb-a022-e3fd027af134

📥 Commits

Reviewing files that changed from the base of the PR and between 66ed6a2 and 777991f.

📒 Files selected for processing (2)
  • src/fosslight_util/download.py
  • tests/test_decide_checkout.py

📝 Walkthrough

Walkthrough

This change updates git checkout ref resolution in download.py. It refines the semver-in-ref regex, adds helpers to extract repository names from git URLs and generate repo-prefixed version candidates, and updates decide_checkout() to resolve tags/branches via these candidates instead of raw hint strings. New tests cover the helpers and integration behavior.

Changes

Repo-prefixed checkout ref resolution

Layer / File(s) Summary
Semver regex and helper functions
src/fosslight_util/download.py
Updates the semver-in-ref regex to recognize v after -/_, and adds _repo_name_from_git_url and _repo_prefixed_version_refs helpers to derive repo names and generate candidate tag/ref strings.
decide_checkout resolution logic
src/fosslight_util/download.py
Updates decide_checkout() to derive repo_name from git_url and iterate repo-prefixed candidates for tag/branch/checkout_to hints, resolving the first match against remote refs instead of matching the raw hint directly.
Unit and integration tests
tests/test_decide_checkout.py
Adds tests for _repo_name_from_git_url, _repo_prefixed_version_refs, _try_resolve_checkout_base (exact and semver-only matches), clarified_version_from_oss_version, and an integration test for decide_checkout with monkeypatched remote refs.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant decide_checkout
  participant RepoNameHelper as _repo_name_from_git_url
  participant CandidateHelper as _repo_prefixed_version_refs
  participant RemoteRefs

  Caller->>decide_checkout: tag/branch/checkout_to, git_url
  decide_checkout->>RepoNameHelper: git_url
  RepoNameHelper-->>decide_checkout: repo_name
  decide_checkout->>CandidateHelper: repo_name, version hint
  CandidateHelper-->>decide_checkout: candidate refs
  decide_checkout->>RemoteRefs: match candidate against refs
  RemoteRefs-->>decide_checkout: resolved ref
Loading

Possibly related PRs

  • fosslight/fosslight_util#259: Both PRs modify decide_checkout()'s semver/ref resolution when interpreting version strings and choosing matching remote refs.
  • fosslight/fosslight_util#264: Both PRs modify decide_checkout/ref-resolution logic to change how semver-tag/v-prefixed versions are matched against remote refs.
  • fosslight/fosslight_util#280: Both PRs extend _try_resolve_checkout_base-style matching behavior in the same ref-resolution code paths.

Suggested labels: bug fix

Suggested reviewers: dd-jy

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: resolving repo-prefixed version tags during checkout.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch v

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@soimkim
soimkim merged commit 106d6cf into main Jul 9, 2026
7 of 8 checks passed
@soimkim
soimkim deleted the v branch July 9, 2026 01:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore [PR/Issue] Refactoring, maintenance the code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant