@cryptotaxi247 / kubo / commits / 3101df56f

install-sharness.sh: implement updates

We want to be able to update Sharness to benefit from new features. License: MIT Signed-off-by: Christian Couder <chriscool@tuxfamily.org>

Christian Couder committed Jun 13, 2015 at 22:29 UTC 3101df56fa5feb04ed78e6340f1ee7ead820625a
1 file changed +28 -7
test/sharness/lib/install-sharness.sh
+28 -7
@@ -11,16 +11,37 @@ 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() {
15 - echo >&2 "$@"
16 - exit 1
21 + echo >&2 "$@"
22 + exit 1
23 }
24
19 -mkdir -p "$clonedir" || die "Could not create '$clonedir' directory"
20 -cd "$clonedir" || die "Could not cd into '$clonedir' directory"
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
22 -git clone "$urlprefix" || die "Could not clone '$urlprefix'"
23 -cd "$sharnessdir" || die "Could not cd into '$sharnessdir' directory"
24 -git checkout "$version" || die "Could not checkout '$version'"
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