Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve ignore patterns #51

Merged
merged 2 commits into from
May 29, 2024
Merged

Preserve ignore patterns #51

merged 2 commits into from
May 29, 2024

Conversation

granawkins
Copy link
Member

No description provided.

Copy link

@mentatai mentatai bot left a comment

Choose a reason for hiding this comment

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

The pull request effectively integrates the use of ignore patterns across different parts of the codebase, ensuring consistency in handling file and directory processing. This is crucial for maintaining the integrity and expected behavior of the application when dealing with file hierarchies. Overall, the changes are well-implemented and align with the goal of preserving ignore patterns throughout the application.

Butler is in closed beta. Reply with feedback or to ask Butler to review other parts of the PR. Please give feedback with emoji reacts.

Comment on lines 73 to +77
for dir in directories:
dir_str = dir.as_posix()
dir_path = dir if dir != Path("ROOT") else Path(".")
document = get_document(dir_str, cwd, type="directory")
document = get_document(
dir_str, cwd, type="directory", ignore_patterns=self.ignore_patterns
Copy link

Choose a reason for hiding this comment

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

Suggested change
for dir in directories:
dir_str = dir.as_posix()
dir_path = dir if dir != Path("ROOT") else Path(".")
document = get_document(dir_str, cwd, type="directory")
document = get_document(
dir_str, cwd, type="directory", ignore_patterns=self.ignore_patterns
document = get_document(
dir_str, cwd, type="directory", ignore_patterns=self.ignore_patterns
)
checksum = hash_str(
"".join(
checksums.get(dir_path / subpath, "")
for subpath in document.split("
")[1:]
)
)

This change ensures that the ignore patterns are consistently applied when generating the document for directories. It's a good practice to maintain consistency in how files and directories are processed, especially when ignore patterns are involved.

Comment on lines 117 to +121
path = cwd if ref == "ROOT" else cwd / ref
paths = sorted([p.as_posix() for p in get_paths_for_directory(path)])
paths = sorted(
[
p.as_posix()
for p in get_paths_for_directory(path, exclude_patterns=ignore_patterns)
Copy link

Choose a reason for hiding this comment

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

Suggested change
path = cwd if ref == "ROOT" else cwd / ref
paths = sorted([p.as_posix() for p in get_paths_for_directory(path)])
paths = sorted(
[
p.as_posix()
for p in get_paths_for_directory(path, exclude_patterns=ignore_patterns)
paths = sorted(
[
p.as_posix()
for p in get_paths_for_directory(path, exclude_patterns=ignore_patterns)
]
)

Including the ignore_patterns in the get_paths_for_directory call here is crucial for maintaining the integrity of the directory processing, ensuring that the ignore patterns are respected across all utility functions.

@granawkins granawkins merged commit 2257a3a into main May 29, 2024
3 checks passed
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.

1 participant