refactor: reorganize zip module into smaller focused files#828
Merged
Conversation
Extract code from the large zip.go file into focused modules: - internal/archiver/: generic zip/unzip utilities - cleanup.go: file cleanup and filtering logic - checksum.go: XXH128 file checksumming - packagist.go: Shopware version lookup via Packagist API This improves code organization, testability, and makes the codebase easier to navigate. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the large zip.go file into smaller, more focused modules to improve code organization and testability. The refactoring extracts generic zip utilities, file cleanup logic, checksumming, and Packagist API integration into separate files while maintaining backward compatibility through proper function exports.
Changes:
- Extracted generic zip/unzip utilities to a new
internal/archiverpackage with comprehensive test coverage - Moved file cleanup and filtering logic to
cleanup.gowith dedicated test file - Moved XXH128 checksumming functionality to
checksum.go - Extracted Shopware version lookup via Packagist API to
packagist.go - Added helper methods (
ResolvePath,ResolveName) toConfigExtraBundlefor consistent path resolution - Added shared helper function
getShopwareVersionConstraintFromComposerto reduce code duplication between PlatformPlugin and ShopwareBundle - Updated all references across the codebase to use the new package structure
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/archiver/zip.go | New package containing generic zip/unzip utilities (Unzip, CreateZip, AddZipFiles) |
| internal/archiver/zip_test.go | Comprehensive tests for archiver package including zip slip security tests |
| internal/extension/cleanup.go | File cleanup and filtering logic extracted from zip.go |
| internal/extension/cleanup_test.go | Comprehensive tests for cleanup functionality |
| internal/extension/checksum.go | XXH128 checksumming logic for extension files |
| internal/extension/packagist.go | Shopware version lookup via Packagist API |
| internal/extension/config.go | Added ResolvePath and ResolveName helper methods to ConfigExtraBundle |
| internal/extension/root.go | Added shared getShopwareVersionConstraintFromComposer helper; updated to import archiver package |
| internal/extension/platform.go | Refactored to use shared getShopwareVersionConstraintFromComposer helper |
| internal/extension/bundle.go | Refactored to use shared getShopwareVersionConstraintFromComposer helper |
| internal/extension/validator_assets.go | Updated to use ConfigExtraBundle.ResolvePath helper |
| internal/extension/asset.go | Updated to use ConfigExtraBundle.ResolveName and ResolvePath helpers |
| internal/extension/git.go | Updated to import and use archiver.Unzip |
| internal/extension/zip.go | Significantly reduced by extracting code to focused modules |
| cmd/extension/extension_zip.go | Updated to use archiver.CreateZip |
| cmd/project/project_extension_upload.go | Updated to use archiver.AddZipFiles |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Extract code from the large zip.go file into focused modules:
This improves code organization, testability, and makes the codebase easier to navigate.