-
-
Notifications
You must be signed in to change notification settings - Fork 149
Fix PreUse hook ctx.installedSdks keying to use version strings #615
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
Conversation
…K names Co-authored-by: bytemain <[email protected]>
Co-authored-by: bytemain <[email protected]>
Co-authored-by: bytemain <[email protected]>
|
@copilot please add more tests for preUse hook of plugin. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #615 +/- ##
=======================================
Coverage 22.60% 22.60%
=======================================
Files 80 80
Lines 5406 5406
=======================================
Hits 1222 1222
Misses 4044 4044
Partials 140 140 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Pull request overview
This PR fixes a regression introduced in version 1.0.0 where the PreUse hook's ctx.installedSdks map was incorrectly keyed by SDK name instead of version string, breaking existing plugins (vfox-elixir, vfox-erlang) that expected version-based indexing.
Changes:
- Changed
ctx.installedSdksmap keying from SDK name to version string in thepreUsefunction - Updated test plugins to use version-based keys (
"1.0.0"instead of"xxxx") with nil checks - Updated documentation in English and Chinese to clarify version-based keying with examples
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/sdk/sdk.go | Core fix: changed map key from sdk.Runtime.Name to string(sdk.Runtime.Version) |
| internal/plugin/plugin_impl_test.go | Updated test to use version string "1.0.0" as key instead of SDK name "xxxx" |
| internal/plugin/testdata/plugins/missing_required_hook/main.lua | Updated to use version-based key with nil check |
| internal/plugin/testdata/plugins/java_with_metadata/hooks/pre_use.lua | Updated to use version-based key with nil check |
| internal/plugin/testdata/plugins/java_with_main/main.lua | Updated to use version-based key with nil check |
| internal/plugin/testdata/plugins/invalid_name/main.lua | Updated to use version-based key with nil check |
| docs/plugins/create/howto.md | Added clarification and examples for version-based keying |
| docs/zh-hans/plugins/create/howto.md | Added clarification and examples for version-based keying (Chinese) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: aooohan <[email protected]>
Added comprehensive test suite for PreUse hook in commit 21b7d51. Created 7 new test cases covering:
All tests pass ✅ |
|
@copilot Please refer to the howto instructions and add unit tests for each hook function which put into plugins_hook_test.go and remove preuse_test.go |
The PreUse hook's
ctx.installedSdkswas changed to key by SDK name instead of version string in 1.0.0, breaking existing plugins (vfox-elixir, vfox-erlang) that index by version.Changes
Core fix:
internal/sdk/sdk.go:459: Changed map key fromsdk.Runtime.Nametostring(sdk.Runtime.Version)Supporting changes:
plugin_impl_test.go: Changed test key from"xxxx"to"1.0.0"to validate correct keyingctx.installedSdkskeys are version strings (e.g.,"1.19.2-elixir-otp-28")Test coverage:
internal/plugin/preuse_test.gowith 7 test cases:Example
Plugins can now access installed SDKs as documented:
Previously this would fail because the map was keyed by SDK name (e.g.,
"elixir") instead of version string (e.g.,"1.19.2-elixir-otp-28").Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.