Skip to content
Open
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
3 changes: 2 additions & 1 deletion nf_core/pipelines/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,10 @@ def get_local_nf_workflow_details(self):
result = nf_core.utils.run_cmd("nextflow", f"info -d {self.full_name}")
if result is not None:
nfinfo_raw, _ = result
nfinfo_str = nfinfo_raw.decode()
re_patterns = {"repository": r"repository\s*: (.*)", "local_path": r"local path\s*: (.*)"}
for key, pattern in re_patterns.items():
m = re.search(pattern, str(nfinfo_raw))
m = re.search(pattern, nfinfo_str)
if m:
value = Path(m.group(1)) if key == "local_path" else m.group(1)
if key == "local_path":
Expand Down
14 changes: 14 additions & 0 deletions tests/pipelines/test_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from pathlib import Path
from unittest import TestCase, mock

import git
import pytest
from rich.console import Console

Expand Down Expand Up @@ -163,6 +164,19 @@ def hexsha(self):

assert local_wf.commit_sha is None

@mock.patch("git.Repo", side_effect=git.InvalidGitRepositoryError("invalid repo"))
@mock.patch("nf_core.utils.run_cmd")
def test_local_workflow_details_decodes_bytes_to_parse_path(self, mock_run_cmd, mock_repo):
local_wf = nf_core.pipelines.list.LocalWorkflow("nf-core/rnaseq")
mock_run_cmd.return_value = (
b"local path : /tmp/.nextflow/assets/nf-core/rnaseq\nrepository : https://github.com/nf-core/rnaseq\n",
b"",
)

local_wf.get_local_nf_workflow_details()
assert local_wf.repository == "https://github.com/nf-core/rnaseq"
assert local_wf.local_path == Path("/tmp/.nextflow/assets/nf-core/rnaseq")

@mock.patch.object(nf_core.pipelines.list.LocalWorkflow, "get_local_nf_workflow_details", autospec=True)
def test_get_local_wf_does_not_scan_unrelated_repos(self, mock_get_local_details):
atacseq_path = self.tmp_nxf / "nf-core" / "atacseq"
Expand Down
Loading