Created
May 19, 2019 21:22
-
-
Save micimize/c314feb46182ddc875aa31f9166ed44d to your computer and use it in GitHub Desktop.
helper to clone a repo for inspection (relatively) cheaply
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
function cheap_clone { | |
EXTERNAL_CLONE_DIR="~/code/external" | |
# mkdir -p $EXTERNAL_CLONE_DIR | |
GIT_HOST='github.com' | |
BRANCH='master' | |
while [[ $# -gt 0 ]] | |
do | |
key="$1" | |
case $key in | |
-h|--host) | |
GIT_HOST=$2 | |
shift # past argument | |
shift # past value | |
;; | |
-b|--branch) | |
BRANCH=$2 | |
shift # past argument | |
shift # past value | |
;; | |
*) | |
REPO=$key | |
shift # past argument | |
;; | |
esac | |
done | |
if [ -z "$REPO" ] | |
then | |
echo $REPO | |
echo "ERROR: positional argument repo must be supplied" | |
return | |
fi | |
cd $EXTERNAL_CLONE_DIR | |
git clone --depth 1 \ | |
--single-branch --branch $BRANCH \ | |
git@${GIT_HOST}:${REPO}.git ${REPO} | |
cd $REPO | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment