git:https-and-ssh: Fix ssh -> https
Apparently there was an issue with the conversion from ssh to https
which I never noticed? The script would replace the colon of the
`https://` and not the one after the domain:
https///github.com:[...]
I rewrote both cases in a simpler way while fixing the issue.
This commit is contained in:
@@ -9,12 +9,12 @@ remote="${1:-origin}"
|
||||
url="$($GIT remote get-url "$remote")"
|
||||
|
||||
if [ "${url##https://}" = "$url" ]; then
|
||||
https_url="https://${url##*@}"
|
||||
https_url="${https_url%%:*}/${https_url#*:}"
|
||||
https_url="${url##*@}"
|
||||
https_url="https://${https_url/:/\/}"
|
||||
$GIT remote set-url "$remote" "$https_url"
|
||||
$GIT remote set-url --push "$remote" "$url"
|
||||
else
|
||||
ssh_url="git@${url#https://}"
|
||||
ssh_url="${ssh_url%%/*}:${ssh_url#*/}"
|
||||
ssh_url="${url#https://}"
|
||||
ssh_url="git@${ssh_url/\//:}"
|
||||
$GIT remote set-url --push "$remote" "$ssh_url"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user