git:https-and-ssh: Swap the if blocks
My brain assumes that the first block handles the case of the url being an https one if I read http in the condition. Swap them and negate the condition for better readability. This might be a symptom of this condition being to complex, but well - it's shell scripting ¯\_(ツ)_/¯
This commit is contained in:
@@ -8,13 +8,13 @@ GIT="git"
|
|||||||
remote="${1:-origin}"
|
remote="${1:-origin}"
|
||||||
url="$($GIT remote get-url "$remote")"
|
url="$($GIT remote get-url "$remote")"
|
||||||
|
|
||||||
if [ "${url##https://}" = "$url" ]; then
|
if [ "${url##https://}" != "$url" ]; then
|
||||||
|
ssh_url="${url#https://}"
|
||||||
|
ssh_url="git@${ssh_url/\//:}"
|
||||||
|
$GIT remote set-url --push "$remote" "$ssh_url"
|
||||||
|
else
|
||||||
https_url="${url##*@}"
|
https_url="${url##*@}"
|
||||||
https_url="https://${https_url/:/\/}"
|
https_url="https://${https_url/:/\/}"
|
||||||
$GIT remote set-url "$remote" "$https_url"
|
$GIT remote set-url "$remote" "$https_url"
|
||||||
$GIT remote set-url --push "$remote" "$url"
|
$GIT remote set-url --push "$remote" "$url"
|
||||||
else
|
|
||||||
ssh_url="${url#https://}"
|
|
||||||
ssh_url="git@${ssh_url/\//:}"
|
|
||||||
$GIT remote set-url --push "$remote" "$ssh_url"
|
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user