From 821163c5b16ed022ea160f22db60d29d751b520f Mon Sep 17 00:00:00 2001 From: Thomas Forgione Date: Tue, 5 Dec 2023 16:35:31 +0100 Subject: [PATCH] Attempt to support non default port for git --- nushell/config/gclone.nu | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/nushell/config/gclone.nu b/nushell/config/gclone.nu index 0371e24..c78a40a 100644 --- a/nushell/config/gclone.nu +++ b/nushell/config/gclone.nu @@ -78,6 +78,8 @@ def gclone [repo_url: string] { $repo_url | parse "https://{server}/{owner}/{repo}" | get 0 } else if ($repo_url | str starts-with "http://") { $repo_url | parse "http://{server}/{owner}/{repo}" | get 0 + } else if ($repo_url | str starts-with "ssh://") { + $repo_url | parse "ssh://git@{server}/{owner}/{repo}" | get 0 } else if ($repo_url | str starts-with "git@") { $repo_url | parse "git@{server}:{owner}/{repo}" | get 0 } else { @@ -90,10 +92,16 @@ def gclone [repo_url: string] { } let server = $attr.server + let server_portless = $attr.server | split row ':' | get 0 let owner = $attr.owner let repo = $attr.repo - let target = [$env.GCLONE_PATH, $server, $owner, $repo] | path join + let target = [$env.GCLONE_PATH, $server_portless, $owner, $repo] | path join + let target = if ($target | str ends-with '.git') { + $target | path parse | update extension "" | get parent stem | str join "/" + } else { + $target + } if ($target | path exists) { print ( @@ -105,7 +113,7 @@ def gclone [repo_url: string] { } let clone_url = if $env.GCLONE_FORCE_SSH { - $attr | format "git@{server}:{owner}/{repo}" + $attr | format "ssh://git@{server}/{owner}/{repo}" } else { $repo_url }