Repository navigation
tool: add pack package for merging scattered config files - #2710
Merged
Merged
Conversation
Implement core Pack functionality for the `xgo pack` command (issue #2709). The package discovers index.* config files in a directory tree, groups them by pack root, merges children into the root using directory-relative paths, and writes consolidated index_pack.* output files. Supports JSON, YAML formats with collision detection, format mismatch validation, test mode (-t) for CI verification, and deterministic output.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2710 +/- ##
=======================================
Coverage 94.12% 94.12%
=======================================
Files 32 32
Lines 10054 10054
=======================================
Hits 9463 9463
Misses 421 421
Partials 170 170 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
Author
There was a problem hiding this comment.
Review Summary
Well-structured Go code with clear separation of concerns, good error messages, and comprehensive test coverage. The implementation is clean and idiomatic. A few items worth addressing:
Key findings:
groupByPackRootdoc claims "nearest ancestor root" but implementation assigns to the shallowest (first) ancestor — behavior mismatch for nested pack roots- Unnecessary loop variable capture (
f := f) given Go 1.24 - Misleading "fatal error" terminology in godoc comments
- Unchecked
os.WriteFileerrors in YAML test helpers - Minor inconsistencies in error message prefixes
Co-authored-by: xgopilot[bot] <231223108+xgopilot[bot]@users.noreply.github.com>
xushiwei
reviewed
Apr 12, 2026
Thread the root directory through the pack call chain and use filepath.Rel to produce root-relative paths in all error messages. This makes err.Error() values deterministic and verifiable in tests. Update error-checking tests to assert exact error strings. Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: xushiwei <396972+xushiwei@users.noreply.github.com>
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.
Summary
Packfunctionality for thexgo packcommand (Proposal:xgo packCommand #2709)index.*config files in a directory tree, groups them by pack root, merges children using directory-relative path segments, and writes consolidatedindex_pack.*outputPackFlagTest) for CI verification, and deterministic outputTest plan
TestPackBasicSPXLayout— verifies the SPX example from the proposalTestPackTestMode— test mode detects missing/stale pack filesTestPackNoConfigFiles— handles empty directory gracefullyTestPackMultipleConfigFormats— detects multiple formats in same dirTestPackCollisionDetection— detects non-object collision at intermediate pathTestPackKeyCollisionAtLeaf— detects key collision at leaf levelTestPackDeterminism— output is deterministic across runsTestPackMultipleRoots— handles multiple independent pack rootsTestPackDeeplyNested— handles deeply nested directory structuresTestPackSkipsSubdirsWithoutConfig— skips asset-only subdirectoriesTestPackYAML— YAML format supportTestPackFormatMismatch— detects root/child format mismatch