Created
August 14, 2015 09:32
-
-
Save sharpner/7d255d7a3a81052a42b3 to your computer and use it in GitHub Desktop.
clone and symlink go open source project
This file contains hidden or 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 | |
repository=github.com | |
if [ -z "$GOPATH" ] ; then | |
echo '$GOPATH not set.' | |
exit 1 | |
fi | |
cd $GOPATH | |
if [ $# -lt 1 ] ; then | |
echo "Usage: goclone group/project [repository]" | |
exit 1 | |
fi | |
if [ ! -z "$2" ] ; then | |
repository=$2 | |
fi | |
group=`echo $1 | cut -f1 -d"/"` | |
project=`echo $1 | cut -f2 -d"/"` | |
if [ -z "$project" ] || [ -z "$group" ] ; then | |
echo "Usage: goclone group/project [repository]" | |
exit 1 | |
fi | |
repo=$1 | |
target=$GOPATH/src/$repository/$group | |
if [ ! -d $target ] ; then | |
mkdir -p $target | |
echo "Created folder "$target | |
fi | |
cd $target | |
git clone git@$repository:$repo.git | |
if [ $? -ne 0 ] ; then | |
echo "Could not clone repository" | |
exit 1 | |
fi | |
symlink=$project | |
cd $GOPATH | |
ln -s $target/$project _$symlink |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you can use motemen/ghq.