fix gitfixremote
This commit is contained in:
@ -2,7 +2,7 @@ def gitfixremote [
|
|||||||
--name: string = "origin",
|
--name: string = "origin",
|
||||||
] {
|
] {
|
||||||
let url = (git remote get-url $name)
|
let url = (git remote get-url $name)
|
||||||
let parsed = ($url | parse --regex '(https://)?(\w*@)?(?P<host>[^/]+)(/|:)(?P<owner>[^/]+)/(?P<repo>[^/\.]+)')
|
let parsed = ($url | parse --regex '^(\w+://)?(\w*@)?(?P<host>[^/:]+)(:(?P<port>\d+))?(:|/)(?P<owner>\w+)/(?P<repo>[\w_-]+)')
|
||||||
|
|
||||||
if ($parsed | is-empty) {
|
if ($parsed | is-empty) {
|
||||||
print "Unparseable remote"
|
print "Unparseable remote"
|
||||||
@ -13,7 +13,7 @@ def gitfixremote [
|
|||||||
|
|
||||||
if ($parsed.host in ["github.com" "git.nubo.sh"]) {
|
if ($parsed.host in ["github.com" "git.nubo.sh"]) {
|
||||||
git remote set-url $name $"https://($parsed.host)/($parsed.owner)/($parsed.repo).git"
|
git remote set-url $name $"https://($parsed.host)/($parsed.owner)/($parsed.repo).git"
|
||||||
git remote set-url --push $name $"($parsed.host):($parsed.owner)/($parsed.repo).git"
|
git remote set-url --push $name $"ssh://($parsed.host)/($parsed.owner)/($parsed.repo).git"
|
||||||
} else {
|
} else {
|
||||||
print $"Unknown host: ($parsed.host)"
|
print $"Unknown host: ($parsed.host)"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user