Skip to content

Instantly share code, notes, and snippets.

@mustafakirimli
Last active April 11, 2019 17:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mustafakirimli/8aba0c1a7d4565b30e3ad9edf8f6bd70 to your computer and use it in GitHub Desktop.
Save mustafakirimli/8aba0c1a7d4565b30e3ad9edf8f6bd70 to your computer and use it in GitHub Desktop.
#!/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