Attempt to support non default port for git

This commit is contained in:
Thomas Forgione 2023-12-05 16:35:31 +01:00
parent 0d469f6989
commit 821163c5b1
1 changed files with 10 additions and 2 deletions

View File

@ -78,6 +78,8 @@ def gclone [repo_url: string] {
$repo_url | parse "https://{server}/{owner}/{repo}" | get 0 $repo_url | parse "https://{server}/{owner}/{repo}" | get 0
} else if ($repo_url | str starts-with "http://") { } else if ($repo_url | str starts-with "http://") {
$repo_url | parse "http://{server}/{owner}/{repo}" | get 0 $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@") { } else if ($repo_url | str starts-with "git@") {
$repo_url | parse "git@{server}:{owner}/{repo}" | get 0 $repo_url | parse "git@{server}:{owner}/{repo}" | get 0
} else { } else {
@ -90,10 +92,16 @@ def gclone [repo_url: string] {
} }
let server = $attr.server let server = $attr.server
let server_portless = $attr.server | split row ':' | get 0
let owner = $attr.owner let owner = $attr.owner
let repo = $attr.repo 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) { if ($target | path exists) {
print ( print (
@ -105,7 +113,7 @@ def gclone [repo_url: string] {
} }
let clone_url = if $env.GCLONE_FORCE_SSH { let clone_url = if $env.GCLONE_FORCE_SSH {
$attr | format "git@{server}:{owner}/{repo}" $attr | format "ssh://git@{server}/{owner}/{repo}"
} else { } else {
$repo_url $repo_url
} }