Last active
December 24, 2015 12:38
-
-
Save mateusreis/6798769 to your computer and use it in GitHub Desktop.
Shell script that clones small framework.
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 | |
# em /usr/local/bin/ | |
CURRENT=`pwd` | |
DIR=`basename $CURRENT` | |
echo " " | |
echo "html1 [branch] Clona um branch específico sem criar um repositório." | |
echo " " | |
echo " Ver lista de branchs em https://github.com/mateusreis/small.git" | |
echo " " | |
# checa se já existem arquivos no diretório | |
if [ "$(ls -A)" ]; then | |
echo 'Diretório não está vazio. Bye!' | |
exit 0 | |
fi | |
# Checa se existe argumento | |
if [ -z "$1" ]; then | |
echo "Entre com o nome do branch:" | |
read BRANCH | |
branch=$BRANCH | |
else | |
branch=$1 | |
fi | |
# checa se o branch existe | |
if ! git ls-remote https://github.com/mateusreis/small.git | grep $branch; then | |
echo "Branch inexistente. Bye!" | |
exit 0 | |
fi | |
# clona o branch | |
if git clone -b $branch https://github.com/mateusreis/small.git .; then | |
echo "Branch clonado com sucesso... " $branch | |
else | |
echo "Erro no clone. Bye!" | |
fi | |
# Deleta o repositório .git | |
rm -Rf .git |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment