Creates Pkg for external consumption#14
Merged
Merged
Conversation
add codeowners file bump to correct Go version
9298940 to
c116c65
Compare
There was a problem hiding this comment.
Pull request overview
This PR extracts the core archive and commit-remapping logic from internal/ into public pkg/ packages so the project can be consumed as a Go library, while updating the CLI/docs and hardening the tar handling.
Changes:
- Introduces
pkg/archivewith newUnTar/ReTarDirimplementations and keepsReTarfor legacy CLI behavior. - Introduces
pkg/commitremapwith public commit-map parsing and metadata rewrite helpers + expanded tests. - Updates CLI, README, workflow, and Go version; removes the obsolete
internal/*implementations/tests.
Show a summary per file
| File | Description |
|---|---|
| pkg/commitremap/commitremap.go | New public commit map parsing + JSON SHA rewriting logic |
| pkg/commitremap/commitremap_test.go | New/expanded tests for parsing, prefix defaults, and rewriting behavior |
| pkg/archive/archive.go | New public tar extraction/creation implementation (security + compatibility oriented) |
| pkg/archive/archive_test.go | Extensive tests for tar safety, edge cases, and legacy layout parity |
| cmd/root.go | Switches CLI imports to pkg/* and uses DefaultPrefixes() |
| README.md | Adds “Using as a library” section and documents limitations |
| .github/workflows/build.yml | Uses go-version-file: go.mod for Go version selection |
| go.mod | Bumps declared Go version to 1.24 |
| internal/archive/archive.go | Removed (superseded by pkg/archive) |
| internal/archive/archive_test.go | Removed (superseded by pkg/archive tests) |
| internal/commitremap/commitremap.go | Removed (superseded by pkg/commitremap) |
| internal/commitremap/commitremap_test.go | Removed (superseded by pkg/commitremap tests) |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 13/13 changed files
- Comments generated: 4
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.
This pull request refactors the project to move the core archive and commit remapping logic from the
internal/directory to a new publicpkg/package, making it available for use as a Go library. It also updates the CLI and documentation to reflect these changes, and improves the archive handling implementation for better security and compatibility. The most important changes are grouped below:Library Extraction and Refactoring
internal/archivetopkg/archive, rewriting it for improved safety, error handling, and standards compliance. This includes a newUnTarandReTarDirimplementation, with legacyReTarpreserved for backward compatibility. ([pkg/archive/archive.goR1-R277](https://github.com/mona-actions/gh-commit-remap/pull/14/files#diff-d73d8d6eb025db679b02c1d5e3209270958f4dbf182e6d05a6646970921d8542R1-R277))internal/commitremaptopkg/commitremap, making the parsing and processing functions accessible for library consumers. ([cmd/root.goL11-R12](https://github.com/mona-actions/gh-commit-remap/pull/14/files#diff-ab967ab1a2f3a1b769106eeb7bfe892ef0e81d1d27811fa15be08e6749feee1fL11-R12))internal/archiveandinternal/commitremapcode and their tests. ([[1]](https://github.com/mona-actions/gh-commit-remap/pull/14/files#diff-944e4f913612b11592545c5323f8b0542d04a0599177f29de14e03a3d93e25baL1-L85),[[2]](https://github.com/mona-actions/gh-commit-remap/pull/14/files#diff-dffb7bab06af83e76768dcafc44e1f9b291acf0b33fd280dc65b970a0bba6ed2L1-L111),[[3]](https://github.com/mona-actions/gh-commit-remap/pull/14/files#diff-9aee514456c5e2d82e4fa7a48ccf1610b747877bbae78cec79c39e358f149c33L1-L129),[[4]](https://github.com/mona-actions/gh-commit-remap/pull/14/files#diff-908f3b040eead50105c334bd5112da44bf75b150350af4b059e01199666a4fedL1-L86))CLI and Workflow Updates
cmd/root.go) to use the newpkg/archiveandpkg/commitremappackages, and switched to usingcommitremap.DefaultPrefixes()for file prefix selection. ([[1]](https://github.com/mona-actions/gh-commit-remap/pull/14/files#diff-ab967ab1a2f3a1b769106eeb7bfe892ef0e81d1d27811fa15be08e6749feee1fL11-R12),[[2]](https://github.com/mona-actions/gh-commit-remap/pull/14/files#diff-ab967ab1a2f3a1b769106eeb7bfe892ef0e81d1d27811fa15be08e6749feee1fL37-L39),[[3]](https://github.com/mona-actions/gh-commit-remap/pull/14/files#diff-ab967ab1a2f3a1b769106eeb7bfe892ef0e81d1d27811fa15be08e6749feee1fL56-R53))go-version-file: go.modfor Go version management, ensuring consistency with the project'sgo.mod. ([.github/workflows/build.ymlL26-R26](https://github.com/mona-actions/gh-commit-remap/pull/14/files#diff-5c3fa597431eda03ac3339ae6bf7f05e1a50d6fc7333679ec38e21b337cb6721L26-R26))Documentation and Go Version
README.mddescribing how to use the remapping and archive logic as a Go library, including sample code and known limitations. ([README.mdR42-R93](https://github.com/mona-actions/gh-commit-remap/pull/14/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5R42-R93))go.modfrom 1.21 to 1.24 to match current standards. ([go.modL3-R3](https://github.com/mona-actions/gh-commit-remap/pull/14/files#diff-33ef32bf6c23acb95f5902d7097b7a1d5128ca061167ec0716715b0b9eeaa5f6L3-R3))