Adding recursive parsing to flatten command#158
Adding recursive parsing to flatten command#158ptrpfn wants to merge 9 commits intoascmitc:masterfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This pull request extends the flatten command functionality by recursively flattening child histories in addition to the root history.
- Added a new test (test_nested) for validating recursive flattening.
- Updated generator and commands modules to support child history processing and handle file movements.
- Introduced a helper function (flatten_child_histories) and modified the commit logic to accommodate flattened manifests.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tests/test_flatten.py | Added a new test to verify nested history flattening. |
| ascmhl/generator.py | Updated commit flow and logging for original hash creation and flattened manifest handling. |
| ascmhl/commands.py | Introduced recursive handling via flatten_child_histories and updated flatten_history accordingly. |
Comments suppressed due to low confidence (1)
tests/test_flatten.py:67
- [nitpick] Consider verifying key output components or using substring assertions instead of an exact string match; this can make the test more robust to minor formatting changes.
assert ( result.output == f"Flattening folder at path: {abspath_conversion_tests('/root')} ...\n" ... )
| if original_hash_entry is None: | ||
| hash_entry.action = "original" | ||
| logger.verbose(f" created original hash for {relative_path} {hash_format}: {hash_string}") | ||
| if relative_path != None: |
There was a problem hiding this comment.
Prefer using 'is not None' instead of '!= None' for clarity and to align with Python best practices.
| if relative_path != None: | |
| if relative_path is not None: |
| # ... or flattened history manifest | ||
| root_path = os.path.dirname(new_hash_list.file_path) | ||
| if not os.path.exists(root_path): | ||
| print(f"ERR: folder {root_path} with flattened manifest does not exist") |
There was a problem hiding this comment.
Consider using a logging method (e.g., logger.error) instead of print for error handling to maintain consistency in the logging approach.
| print(f"ERR: folder {root_path} with flattened manifest does not exist") | |
| logger.error(f"Folder {root_path} with flattened manifest does not exist") |
|
|
||
| # if os.path.isabs(file_path): |
There was a problem hiding this comment.
[nitpick] Remove unused commented out code to improve clarity and maintainability.
| # if os.path.isabs(file_path): |
|
covered by pull request #166 |
The
flattencommand only flattened the root history, but not child histories. Including the hashes from the child histories was missing in the implementation and is added with this pull request.