File tree 3 files changed +53
-2
lines changed
3 files changed +53
-2
lines changed Original file line number Diff line number Diff line change @@ -24,4 +24,5 @@ Default brings logger support. See https://github.com/completeworks/b-log#exampl
24
24
25
25
* ` gitw sparsecheckout <remote> <path:.> <branch:master> `
26
26
* ` download withcache <url> <output> <cache_duration_sec:24h> <lastchecked_file:${output}.lastchecked> `
27
- * ` download ifmodified <url> <output> <etag_file:${output}.etag> `
27
+ * ` download ifmodified <url> <output> <etag_file:${output}.etag> `
28
+ * ` version compare <version1> <version2> `
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ sparsecheckout() {
32
32
git -C " ${path} " config --add remote.origin.fetch " +refs/heads/${branch} :refs/remotes/origin/${branch} " | & TRACE
33
33
git -C " ${path} " config core.sparsecheckout true | & TRACE
34
34
git -C " ${path} " config advice.detachedHead false | & TRACE
35
- INFO " Checking out ${branch} ..."
35
+ INFO " Checking out branch ${branch} ..."
36
36
git -C " ${path} " checkout --no-progress -f " $( git -C " ${path} " rev-parse " refs/remotes/origin/${branch} " ) " | & TRACE
37
37
fi
38
38
}
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+ # *******************************************************************************
3
+ # Copyright (c) 2020 Eclipse Foundation and others.
4
+ # This program and the accompanying materials are made available
5
+ # under the terms of the Eclipse Public License 2.0
6
+ # which is available at http://www.eclipse.org/legal/epl-v20.html,
7
+ # or the MIT License which is available at https://opensource.org/licenses/MIT.
8
+ # SPDX-License-Identifier: EPL-2.0 OR MIT
9
+ # *******************************************************************************
10
+
11
+ # shellcheck disable=SC1090
12
+ . " $( dirname " $( readlink -f " ${BASH_SOURCE[0]} " ) " ) /_bootstrap.shsource"
13
+
14
+ # from https://stackoverflow.com/a/4025065
15
+ compare () {
16
+ if [[ " ${1} " == " ${2} " ]]; then
17
+ echo " 0"
18
+ return
19
+ fi
20
+
21
+ local IFS=.
22
+ read -ra ver1 <<< " ${1}"
23
+ read -ra ver2 <<< " ${2}"
24
+
25
+ local i
26
+ # fill empty fields in ver1 with zeros
27
+ for (( i= ${# ver1[@]} ; i< ${# ver2[@]} ; i++ )) ; do
28
+ ver1[i]=0
29
+ done
30
+
31
+ for (( i= 0 ; i< ${# ver1[@]} ; i++ )) ; do
32
+ if [[ -z ${ver2[i]:- } ]]; then
33
+ # fill empty fields in ver2 with zeros
34
+ ver2[i]=0
35
+ fi
36
+ if (( 10 #${ver1[i]} > 10 #${ver2[i]} )) ; then
37
+ echo " 1"
38
+ return
39
+ fi
40
+ if (( 10 #${ver1[i]} < 10 #${ver2[i]} )) ; then
41
+ echo " -1"
42
+ return
43
+ fi
44
+ done
45
+
46
+ echo " 0"
47
+ }
48
+
49
+ # shellcheck disable=SC2068
50
+ $@
You can’t perform that action at this time.
0 commit comments