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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages=["ragdaemon"]

[project]
name = "ragdaemon"
version = "0.7.3"
version = "0.7.4"
description = "Generate and render a call graph for a Python project."
readme = "README.md"
dependencies = [
Expand Down
2 changes: 1 addition & 1 deletion ragdaemon/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.7.3"
__version__ = "0.7.4"
6 changes: 4 additions & 2 deletions ragdaemon/annotators/hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,12 @@ async def annotate(
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
Comment on lines 73 to +77
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.

)
checksum = hash_str(
"".join(
checksums[dir_path / subpath]
checksums.get(dir_path / subpath, "")
for subpath in document.split("\n")[1:]
)
)
Expand Down
11 changes: 9 additions & 2 deletions ragdaemon/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ def parse_diff_id(id: str) -> tuple[str, Path | None, set[int] | None]:
return diff_ref, path, lines


def get_document(ref: str, cwd: Path, type: str = "file") -> str:
def get_document(
ref: str, cwd: Path, type: str = "file", ignore_patterns: set[Path] = set()
) -> str:
if type == "diff":
if ":" in ref:
diff_ref, lines_ref = ref.split(":", 1)
Expand All @@ -113,7 +115,12 @@ def get_document(ref: str, cwd: Path, type: str = "file") -> str:

elif type == "directory":
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)
Comment on lines 117 to +121
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.

]
)
text = "\n".join(paths)

elif type in {"file", "chunk"}:
Expand Down
Loading