Skip to content

Commit

Permalink
Preserve ignore patterns (#51)
Browse files Browse the repository at this point in the history
* pass ignore_patterns to get_document for directories

* version bump
  • Loading branch information
granawkins authored May 29, 2024
1 parent 0a7ef1f commit 2257a3a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
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
)
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)
]
)
text = "\n".join(paths)

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

0 comments on commit 2257a3a

Please sign in to comment.