Skip to content

Commit b85e27c

Browse files
committed
Update install.sh
1 parent 1788a2c commit b85e27c

File tree

3 files changed

+53
-2
lines changed

3 files changed

+53
-2
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ Default brings logger support. See https://github.com/completeworks/b-log#exampl
2424

2525
* `gitw sparsecheckout <remote> <path:.> <branch:master>`
2626
* `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>`

install.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ sparsecheckout() {
3232
git -C "${path}" config --add remote.origin.fetch "+refs/heads/${branch}:refs/remotes/origin/${branch}" |& TRACE
3333
git -C "${path}" config core.sparsecheckout true |& TRACE
3434
git -C "${path}" config advice.detachedHead false |& TRACE
35-
INFO "Checking out ${branch}..."
35+
INFO "Checking out branch ${branch}..."
3636
git -C "${path}" checkout --no-progress -f "$(git -C "${path}" rev-parse "refs/remotes/origin/${branch}")" |& TRACE
3737
fi
3838
}

versions

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
$@

0 commit comments

Comments
 (0)