Skip to content

Creates Pkg for external consumption#14

Merged
amenocal merged 4 commits into
mainfrom
feature/create-pkg
Apr 29, 2026
Merged

Creates Pkg for external consumption#14
amenocal merged 4 commits into
mainfrom
feature/create-pkg

Conversation

@amenocal
Copy link
Copy Markdown
Collaborator

This pull request refactors the project to move the core archive and commit remapping logic from the internal/ directory to a new public pkg/ 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

  • Moved archive extraction and packaging logic from internal/archive to pkg/archive, rewriting it for improved safety, error handling, and standards compliance. This includes a new UnTar and ReTarDir implementation, with legacy ReTar preserved for backward compatibility. ([pkg/archive/archive.goR1-R277](https://github.com/mona-actions/gh-commit-remap/pull/14/files#diff-d73d8d6eb025db679b02c1d5e3209270958f4dbf182e6d05a6646970921d8542R1-R277))
  • Moved commit remapping logic from internal/commitremap to pkg/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))
  • Removed the now-obsolete internal/archive and internal/commitremap code 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

  • Updated the CLI (cmd/root.go) to use the new pkg/archive and pkg/commitremap packages, and switched to using commitremap.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))
  • Updated the GitHub Actions workflow to use go-version-file: go.mod for Go version management, ensuring consistency with the project's go.mod. ([.github/workflows/build.ymlL26-R26](https://github.com/mona-actions/gh-commit-remap/pull/14/files#diff-5c3fa597431eda03ac3339ae6bf7f05e1a50d6fc7333679ec38e21b337cb6721L26-R26))

Documentation and Go Version

  • Added a new section to the README.md describing 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))
  • Updated the Go version in go.mod from 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))

@amenocal amenocal force-pushed the feature/create-pkg branch from 9298940 to c116c65 Compare April 28, 2026 23:21
Copy link
Copy Markdown

Copilot AI left a 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 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/archive with new UnTar/ReTarDir implementations and keeps ReTar for legacy CLI behavior.
  • Introduces pkg/commitremap with 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

Comment thread pkg/archive/archive.go
Comment thread README.md Outdated
Comment thread pkg/archive/archive.go
Comment thread pkg/archive/archive.go
@amenocal amenocal merged commit c9e8463 into main Apr 29, 2026
1 check passed
@amenocal amenocal deleted the feature/create-pkg branch April 29, 2026 19:51
@amenocal amenocal mentioned this pull request Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants