Derive directory roots for artifact scanning
This commit is contained in:
parent
ce48dee42c
commit
c2ddb08135
@ -23,14 +23,16 @@ class ArtifactManager:
|
||||
normalized_pattern = pattern.replace("\\", "/")
|
||||
segments = [segment for segment in normalized_pattern.split("/") if segment and segment != "."]
|
||||
prefix: list[str] = []
|
||||
saw_glob = False
|
||||
for segment in segments:
|
||||
if any(char in segment for char in "*?["):
|
||||
saw_glob = True
|
||||
break
|
||||
prefix.append(segment)
|
||||
if prefix:
|
||||
roots.append(root_dir.joinpath(*prefix))
|
||||
continue
|
||||
roots.append(root_dir)
|
||||
candidate = root_dir.joinpath(*prefix) if prefix else root_dir
|
||||
if prefix and not saw_glob and (not candidate.exists() or candidate.is_file()):
|
||||
candidate = candidate.parent
|
||||
roots.append(candidate)
|
||||
minimal_roots: list[Path] = []
|
||||
for root in sorted(set(roots), key=lambda candidate: (len(candidate.parts), candidate.as_posix())):
|
||||
if any(existing == root or existing in root.parents for existing in minimal_roots):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user