Skip to content

Adding recursive parsing to flatten command#158

Closed
ptrpfn wants to merge 9 commits intoascmitc:masterfrom
ptrpfn:dev/flatten-recursive
Closed

Adding recursive parsing to flatten command#158
ptrpfn wants to merge 9 commits intoascmitc:masterfrom
ptrpfn:dev/flatten-recursive

Conversation

@ptrpfn
Copy link
Collaborator

@ptrpfn ptrpfn commented Feb 18, 2025

The flatten command 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.

@pfn-asm pfn-asm requested a review from Copilot May 16, 2025 13:44
Copy link

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 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:
Copy link

Copilot AI May 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer using 'is not None' instead of '!= None' for clarity and to align with Python best practices.

Suggested change
if relative_path != None:
if relative_path is not None:

Copilot uses AI. Check for mistakes.
# ... 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")
Copy link

Copilot AI May 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using a logging method (e.g., logger.error) instead of print for error handling to maintain consistency in the logging approach.

Suggested change
print(f"ERR: folder {root_path} with flattened manifest does not exist")
logger.error(f"Folder {root_path} with flattened manifest does not exist")

Copilot uses AI. Check for mistakes.
Comment on lines +1249 to +1250

# if os.path.isabs(file_path):
Copy link

Copilot AI May 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Remove unused commented out code to improve clarity and maintainability.

Suggested change
# if os.path.isabs(file_path):

Copilot uses AI. Check for mistakes.
@pfn-asm
Copy link
Collaborator

pfn-asm commented Jul 4, 2025

covered by pull request #166

@pfn-asm pfn-asm closed this Jul 4, 2025
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.

3 participants