-
-
Notifications
You must be signed in to change notification settings - Fork 1k
refactor: ExtraOr, MustExtra #5685
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
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 refactors how extra metadata is accessed in artifacts by replacing usage of Extra and ExtraOr with MustExtra, simplifying error handling by panicking when keys are missing or type assertions fail. It also removes the legacy Extra behavior and introduces the MustExtra function.
- Replaces fallback logic with panic-based error handling for incorrectly set or missing keys.
- Removes the Extra function and updates various tests and pipeline modules to use MustExtra consistently.
- Adjusts related logic (e.g. in brew and archive code) to use the new MustExtra and artifact.Ext() helpers.
Reviewed Changes
Copilot reviewed 23 out of 25 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
internal/pipe/scoop/scoop_test.go | Updated tests to work with MustExtra usage changes. |
internal/pipe/scoop/scoop.go | Refactored artifact extra fetching via MustExtra. |
internal/pipe/nix/nix.go | Updated key fetching with cmp.Or and MustExtra. |
internal/pipe/nfpm/nfpm_test.go | Replaced ExtraOr calls with MustExtra. |
internal/pipe/krew/krew.go | Changed extra handling to use MustExtra. |
internal/pipe/docker/{docker_test.go, docker.go} | Replaced error-based extra fetching with MustExtra. |
internal/pipe/chocolatey/chocolatey.go | Updated to use MustExtra in publishing logic. |
internal/pipe/checksums/checksums_test.go | Updated to use MustExtra instead of Extra. |
internal/pipe/brew/{brew_test.go, brew.go} | Changed extra fetching; in brew.go ensure fallback removal. |
internal/pipe/aursources/aursources.go | Updated formatting extraction to use artifact.Format(). |
internal/pipe/aur/aur.go | Refactored for MustExtra extractions. |
internal/pipe/archive/{archive_test.go, archive.go} | Replaced ExtraOr with MustExtra and artifact.Ext(). |
internal/artifact/{artifact_test.go, artifact.go} | Central refactor of extra handling and tests. |
Files not reviewed (2)
- internal/pipe/scoop/testdata/TestRunPipePullRequest.json.golden: Language not supported
- internal/pipe/scoop/testdata/Test_doRun/git_remote.json.golden: Language not supported
Comments suppressed due to low confidence (2)
internal/pipe/brew/brew.go:370
- [nitpick] Replacing the default fallback with MustExtra here can lead to panics if 'ExtraBinary' is missing; ensure that 'ExtraBinary' is always populated or provide an explicit default to avoid runtime issues.
bin := artifact.MustExtra[string](*art, artifact.ExtraBinary)
internal/artifact/artifact_test.go:483
- [nitpick] The test for unmarshal error depends on an exact JSON error message, which might change with library updates; consider checking for a substring or error type to make the test more resilient.
require.PanicsWithError(t, "json: unknown field \"repository\"", func() {
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5685 +/- ##
==========================================
+ Coverage 82.81% 82.99% +0.18%
==========================================
Files 158 158
Lines 15579 15545 -34
==========================================
Hits 12901 12901
+ Misses 2111 2088 -23
+ Partials 567 556 -11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ExtraOr
is being used we actually expect the key to be thereExtra
behavior was kind of the same ofExtraOr
in some situationsThis PR:
ExtraOr
by only returningor
if the key doesn't exist, and panics if it cannot be cast into the expected type - which is the intended usageExtra
functionMustExtra
function which panics if the key doesn't exist, or if it cannot be cast to the expected type