Skip to content
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
18 changes: 13 additions & 5 deletions planemo/ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@

from planemo import git
from planemo import io
from planemo.shed import SHED_CONFIG_NAME


def filter_paths(ctx, raw_paths, path_type="dir", **kwds):
def filter_paths(ctx, raw_paths, path_type="repo", **kwds):
"""Filter ``paths``.

``path_type`` is ``dir`` or ``file``.
``path_type`` is ``repo`` or ``file``.
"""
cwd = os.getcwd()

Expand All @@ -22,11 +23,18 @@ def filter_paths(ctx, raw_paths, path_type="dir", **kwds):
diff_paths = None
if changed_in_commit_range is not None:
diff_files = git.diff(ctx, cwd, changed_in_commit_range)
if path_type == "dir":
diff_paths = [os.path.dirname(p) for p in diff_files]
if path_type == "repo":
diff_dirs = set(os.path.dirname(p) for p in diff_files)
diff_paths = set()
for diff_dir in diff_dirs:
while diff_dir:
if os.path.isfile(os.path.join(diff_dir, SHED_CONFIG_NAME)):
diff_paths.add(diff_dir)
break
diff_dir = os.path.dirname(diff_dir)
else:
diff_paths = diff_files
diff_paths = sorted(set(diff_paths))
diff_paths = sorted(diff_paths)

unique_paths = sorted(set(map(lambda p: os.path.relpath(p, cwd), raw_paths)))
filtered_paths = io.filter_paths(unique_paths, cwd=cwd, **filter_kwds)
Expand Down
2 changes: 1 addition & 1 deletion planemo/commands/cmd_ci_find_repos.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ def cli(ctx, paths, **kwds):
# Since fail_fast is True, all repos are actual raw repo objects and
# not exceptions.
raw_paths = [r.path for r in repos]
paths = filter_paths(ctx, raw_paths, path_type="dir", **kwds)
paths = filter_paths(ctx, raw_paths, path_type="repo", **kwds)
print_path_list(paths, **kwds)