-
Notifications
You must be signed in to change notification settings - Fork 598
fix(copilot-cli): use semver sort for prerelease tag resolution #1657
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Copilot
wants to merge
5
commits into
main
Choose a base branch
from
copilot/copilot-cli-fix-prerelease-tag-sort
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
aceee79
Initial plan
Copilot 63f4f14
fix(copilot-cli): use semver sort for prerelease tag resolution
Copilot d748a8e
Merge branch 'main' into copilot/copilot-cli-fix-prerelease-tag-sort
Kaniska244 e38d64b
refactor(copilot-cli): extract resolve_prerelease_version function an…
Copilot fb8ecf6
fix(copilot-cli): make repo_url mandatory in resolve_prerelease_version
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -e | ||
|
|
||
| # Optional: Import test library | ||
| source dev-container-features-test-lib | ||
|
|
||
| # Define the function under test (matches src/copilot-cli/install.sh) | ||
| resolve_prerelease_version() { | ||
| local repo_url="${1:?resolve_prerelease_version requires a repository URL}" | ||
| git ls-remote --tags "${repo_url}" \ | ||
| | awk '{print $2}' | sed 's|refs/tags/||' \ | ||
| | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9]+)?$' \ | ||
| | sort -V | tail -n1 | ||
| } | ||
|
|
||
| # Create a mock git script that returns controlled output | ||
| MOCK_DIR="$(mktemp -d)" | ||
| cat > "${MOCK_DIR}/git" << 'SCRIPT' | ||
| #!/bin/bash | ||
| # Return mock ls-remote output based on the repo URL argument | ||
| repo="${*: -1}" | ||
| case "${repo}" in | ||
| "mock://basic") | ||
| printf 'abc1234\trefs/tags/v1.0.1\ndef5678\trefs/tags/v1.0.9\nghi9012\trefs/tags/v1.0.10\njkl3456\trefs/tags/v1.0.45\nmno7890\trefs/tags/v1.0.2\n' | ||
| ;; | ||
| "mock://prerelease") | ||
| printf 'abc1234\trefs/tags/v1.0.44\ndef5678\trefs/tags/v1.0.45-1\nghi9012\trefs/tags/v1.0.45-10\njkl3456\trefs/tags/v1.0.45-2\nmno7890\trefs/tags/v1.0.45\n' | ||
| ;; | ||
| "mock://stray") | ||
| printf 'abc1234\trefs/tags/latest\ndef5678\trefs/tags/v1.0.3\nghi9012\trefs/tags/nightly\njkl3456\trefs/tags/v1.0.20\n' | ||
| ;; | ||
| esac | ||
| SCRIPT | ||
| chmod +x "${MOCK_DIR}/git" | ||
| export PATH="${MOCK_DIR}:${PATH}" | ||
|
|
||
| # Test: version sort picks v1.0.45, not v1.0.9 | ||
| result="$(resolve_prerelease_version "mock://basic")" | ||
| check "picks highest version (v1.0.45)" bash -c "[ '${result}' = 'v1.0.45' ]" | ||
|
|
||
| # Test: prerelease numeric suffixes sort correctly | ||
| result2="$(resolve_prerelease_version "mock://prerelease")" | ||
| check "picks highest prerelease (v1.0.45-10)" bash -c "[ '${result2}' = 'v1.0.45-10' ]" | ||
|
|
||
| # Test: filters out non-version tags | ||
| result3="$(resolve_prerelease_version "mock://stray")" | ||
| check "ignores non-version tags" bash -c "[ '${result3}' = 'v1.0.20' ]" | ||
|
|
||
| # Cleanup | ||
| rm -rf "${MOCK_DIR}" | ||
|
|
||
| # Report result | ||
| reportResults | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "resolve_prerelease_version": { | ||
| "image": "ubuntu:noble", | ||
| "features": { | ||
| "copilot-cli": { | ||
| "version": "latest" | ||
| } | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My intention was that we test just this part (without the git part to simplify tests), and also without rewriting the function. Happy to approve to unblock this but would appreciate if we can have this as a follow-up.