Skip to content

Instantly share code, notes, and snippets.

@vrdhn vrdhn/eip.sh
Created Feb 26, 2017

Embed
What would you like to do?
elm package install, by cloning specific branch from a shared locally cloned git repo
#!/bin/sh
## elm-get owner/repo ver
repo=$1
ver=$2
giturl=git@github.com:$repo
gitlocal=/data/Elm/$repo
pkgdir=$(pwd)/elm-stuff/packages/$repo/$ver
echo $pkgdir
## if pkgdir exists .. we are done
if [ -d $pkgdir ] ; then
echo "Exists: $pkgdir"
exit 0
else
echo "Will make $pkgdir"
fi
## Checkout if doesn't exist ..
if [ ! -e $gitlocal/.git ] ; then
echo "Cloning $giturl to $gitlocal"
mkdir -p $(dirname $gitlocal)
git clone $giturl $gitlocal
else
echo "Found git reop $gitlocal"
fi
## Makesure version exist ...
found=0
if ( cd $gitlocal; git tag | grep '^'$ver'$' ) ; then
echo "Version $ver found"
found=1
fi
## Git update ... in case of new branch
if [ $found = 0 ] ; then
echo "Version $ver not found; will git pull once"
( cd $gitlocal; git pull )
fi
## still not found after git update ?
if ( cd $gitlocal; git tag | grep '^'$ver'$' ) ; then
echo "Version $ver found"
found=1
fi
## exit..
if [ $found = 0 ] ; then
echo "Error : Version $ver not found for $repo"
echo $( cd $gitlocal; git tag )
exit 1
fi
## And checkit out..
mkdir -p $(dirname $pkgdir)
git clone --branch $ver --single-branch --depth 1 file://$gitlocal $pkgdir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.