github.com/whyrusleeping/gx@v0.14.3/tests/lib/install-sharness.sh (about) 1 #!/bin/sh 2 # install sharness.sh 3 # 4 # Copyright (c) 2014 Juan Batiz-Benet 5 # MIT Licensed; see the LICENSE file in this repository. 6 # 7 8 # settings 9 version=5eee9b51b5621cec95a64018f0cc779963b230d2 10 urlprefix=https://github.com/mlafeldt/sharness.git 11 clonedir=lib 12 sharnessdir=sharness 13 14 if test -f "$clonedir/$sharnessdir/SHARNESS_VERSION_$version" 15 then 16 # There is the right version file. Great, we are done! 17 exit 0 18 fi 19 20 die() { 21 echo >&2 "$@" 22 exit 1 23 } 24 25 checkout_version() { 26 git checkout "$version" || die "Could not checkout '$version'" 27 rm -f SHARNESS_VERSION_* || die "Could not remove 'SHARNESS_VERSION_*'" 28 touch "SHARNESS_VERSION_$version" || die "Could not create 'SHARNESS_VERSION_$version'" 29 echo "Sharness version $version is checked out!" 30 } 31 32 if test -d "$clonedir/$sharnessdir/.git" 33 then 34 # We need to update sharness! 35 cd "$clonedir/$sharnessdir" || die "Could not cd into '$clonedir/$sharnessdir' directory" 36 git fetch || die "Could not fetch to update sharness" 37 checkout_version 38 else 39 # We need to clone sharness! 40 mkdir -p "$clonedir" || die "Could not create '$clonedir' directory" 41 cd "$clonedir" || die "Could not cd into '$clonedir' directory" 42 43 git clone "$urlprefix" || die "Could not clone '$urlprefix'" 44 cd "$sharnessdir" || die "Could not cd into '$sharnessdir' directory" 45 checkout_version 46 fi 47 exit 0