Merged
Conversation
martinemde
approved these changes
Feb 4, 2026
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 of Changes
lib/parse_packwerk/package.rbAdded original_key_order field to the Package struct to store the key order from the original YAML file
Updated Package.from to capture and store the original key order when reading a package.yml file
lib/parse_packwerk.rbAdded preserve_key_order configuration option (defaults to false for backwards compatibility)
Added sort_keys helper method that:
When preserve_key_order is true and original order exists: preserves existing keys in their original order, appends new keys in canonical order
When preserve_key_order is false (default): sorts keys according to key_sort_order (existing behavior)
spec/parse_packwerk_spec.rbAdded tests covering:
Usage
To enable key order preservation:
ParsePackwerk.preserve_key_order = true
This will cause write_package_yml! to preserve the original key order from the file, reducing diff churn when tools like packs move packages around. New keys added during write will be appended in the canonical sort order.