Last active
April 11, 2019 17:33
-
-
Save mustafakirimli/8aba0c1a7d4565b30e3ad9edf8f6bd70 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
declare -a CF_ACCESS_HOSTS=( | |
"https://gitlab.mywebsite.com" | |
"https://gitlab.mycompany.com" | |
) | |
is_cf_git_host() { | |
host_name=$(echo "$1" | awk -F/ '{print $3}') | |
printf '%s\n' "${CF_ACCESS_HOSTS[@]}" | grep --quiet "$host_name"; | |
} | |
call_cloudflared() { | |
if is_cf_git_host "${1}"; then | |
cloudflared access gitConfig $1; | |
fi | |
} | |
git () { | |
if [ "$1" == "clone" ]; then | |
call_cloudflared $2 | |
elif [ -d "${PWD}/.git" ]; then | |
call_cloudflared $(command git config --get remote.origin.url) | |
fi | |
command git $@; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment