Skip to content

Commit 4506911

Browse files
committed
feat(codetide): add relative_directories property and update cached_ids
1 parent 95a30e7 commit 4506911

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

codetide/__init__.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,17 @@ def relative_filepaths(self)->List[str]:
9898
return [
9999
str(filepath.relative_to(self.rootpath)).replace("\\", "/") for filepath in self.files
100100
]
101-
101+
102+
@property
103+
def relative_directories(self) -> List[str]:
104+
dirs = set()
105+
for filepath in self.files:
106+
p = filepath.resolve().parent
107+
while p != self.rootpath:
108+
dirs.add(p.relative_to(self.rootpath).as_posix())
109+
p = p.parent
110+
return sorted(dirs)
111+
102112
@property
103113
def filenames_mapped(self)->Dict[str, str]:
104114
return {
@@ -108,7 +118,7 @@ def filenames_mapped(self)->Dict[str, str]:
108118

109119
@property
110120
def cached_ids(self)->List[str]:
111-
return self.codebase.non_import_unique_ids+self.relative_filepaths
121+
return self.codebase.non_import_unique_ids + self.relative_filepaths + self.relative_directories
112122

113123
@property
114124
def repo(self)->Optional[pygit2.Repository]:

0 commit comments

Comments
 (0)