@@ -134,14 +134,22 @@ def _calc_changed_paths(
134
134
"""
135
135
TODO(pankaj) add support for directory creation in patch
136
136
"""
137
- unignored_paths = _calc_unignored_paths (root , ignore_patterns )
137
+ root_relative_new_paths = set (
138
+ (str (path .relative_to (root )) for path in root .glob ("**/*" ))
139
+ )
140
+ unignored_new_paths = _calc_unignored_paths (
141
+ root , root_relative_new_paths , ignore_patterns
142
+ )
138
143
previous_root_relative_paths = set (previous_root_path_content_hashes .keys ())
144
+ unignored_prev_paths = _calc_unignored_paths (
145
+ root , previous_root_relative_paths , ignore_patterns
146
+ )
139
147
140
- added_paths = unignored_paths - previous_root_relative_paths
141
- removed_paths = previous_root_relative_paths - unignored_paths
148
+ added_paths = unignored_new_paths - unignored_prev_paths
149
+ removed_paths = unignored_prev_paths - unignored_new_paths
142
150
143
151
updated_paths = set ()
144
- common_paths = unignored_paths .intersection (previous_root_relative_paths )
152
+ common_paths = unignored_new_paths .intersection (unignored_prev_paths )
145
153
for path in common_paths :
146
154
full_path : Path = root / path
147
155
if full_path .is_file ():
@@ -158,7 +166,9 @@ def _calc_changed_paths(
158
166
159
167
160
168
def _calc_unignored_paths (
161
- root : Path , ignore_patterns : Optional [List [str ]] = None
169
+ root : Path ,
170
+ root_relative_paths : Set [str ],
171
+ ignore_patterns : Optional [List [str ]] = None ,
162
172
) -> Set [str ]:
163
173
root_relative_ignored_paths = set ()
164
174
if ignore_patterns is not None :
@@ -168,9 +178,6 @@ def _calc_unignored_paths(
168
178
)
169
179
root_relative_ignored_paths .update (ignored_paths_for_pattern )
170
180
171
- root_relative_paths = set (
172
- (str (path .relative_to (root )) for path in root .glob ("**/*" ))
173
- )
174
181
return root_relative_paths - root_relative_ignored_paths
175
182
176
183
0 commit comments