Skip to content

Commit

Permalink
Merge pull request #2945 from nf-core/handle-ssh-git-paths
Browse files Browse the repository at this point in the history
Components: Handle extended set of git path prefixes
  • Loading branch information
mirpedrol authored May 6, 2024
2 parents a0d55b7 + 32fda2c commit 2e7ba04
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

### Components

- Handle more complete list of possible git URL forms (ssh:// and ftp:// prefixes specifically) ([#2945](https://github.com/nf-core/tools/pull/2945))

### General

- Update CI to use nf-core/setup-nextflow v2
Expand Down
25 changes: 12 additions & 13 deletions nf_core/modules/modules_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,19 @@ def repo_full_name_from_remote(remote_url: str) -> str:
Extracts the path from the remote URL
See https://mirrors.edge.kernel.org/pub/software/scm/git/docs/git-clone.html#URLS for the possible URL patterns
"""
# Check whether we have a https or ssh url
if remote_url.startswith("https"):
path = urlparse(remote_url).path
# Remove the intial '/'
path = path[1:]
# Remove extension
path = os.path.splitext(path)[0]

if remote_url.startswith(("https://", "http://", "ftps://", "ftp://", "ssh://")):
# Parse URL and remove the initial '/'
path = urlparse(remote_url).path.lstrip("/")
elif "git@" in remote_url:
# Extract the part after 'git@' and parse it
path = urlparse(remote_url.split("git@")[-1]).path
else:
# Remove the initial `git@``
split_path: list = remote_url.split("@")
path = split_path[-1] if len(split_path) > 1 else split_path[0]
path = urlparse(path).path
# Remove extension
path = os.path.splitext(path)[0]
path = urlparse(remote_url).path

# Remove the file extension from the path
path, _ = os.path.splitext(path)

return path


Expand Down

0 comments on commit 2e7ba04

Please sign in to comment.