Skip to content

Commit b0de5a6

Browse files
committed
refactor: simplify install.sh
1 parent 11128c5 commit b0de5a6

File tree

3 files changed

+11
-17
lines changed

3 files changed

+11
-17
lines changed

install.sh

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,6 @@ function is_git_installed() {
66
command -v git > /dev/null 2>&1
77
}
88

9-
function get_latest_tag() {
10-
local repository_url=$1
11-
12-
git ls-remote --tags "$repository_url" |
13-
awk '{print $2}' |
14-
sed 's|^refs/tags/||' |
15-
sort -Vr |
16-
head -n 1
17-
}
18-
199
function build_and_install_beta() {
2010
echo "> Downloading non-stable version: 'beta'"
2111

@@ -92,11 +82,7 @@ elif [[ $# -eq 2 ]]; then
9282
fi
9383

9484
BASHUNIT_GIT_REPO="https://github.com/TypedDevs/bashunit"
95-
if is_git_installed; then
96-
LATEST_BASHUNIT_VERSION="$(get_latest_tag "$BASHUNIT_GIT_REPO")"
97-
else
98-
LATEST_BASHUNIT_VERSION="0.22.2"
99-
fi
85+
LATEST_BASHUNIT_VERSION="0.22.2"
10086
TAG="$LATEST_BASHUNIT_VERSION"
10187

10288
cd "$(dirname "$0")"

src/env.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,17 @@ function env::is_no_output_enabled() {
8787
}
8888

8989
function env::active_internet_connection() {
90+
if [[ "${BASHUNIT_NO_NETWORK:-}" == "true" ]]; then
91+
return 1
92+
fi
93+
9094
if command -v curl >/dev/null 2>&1; then
9195
curl -sfI https://github.com >/dev/null 2>&1 && return 0
9296
elif command -v wget >/dev/null 2>&1; then
9397
wget -q --spider https://github.com && return 0
9498
fi
9599

96-
if ping -c 1 -W 3 github.com &> /dev/null; then
100+
if ping -c 1 -W 3 google.com &> /dev/null; then
97101
return 0
98102
fi
99103

tests/acceptance/bashunit_upgrade_test.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ function tear_down_after_script() {
2828

2929
function set_up() {
3030
./build.sh "$TMP_DIR" >/dev/null
31-
LATEST_VERSION="$(helpers::get_latest_tag)"
31+
if [[ "$ACTIVE_INTERNET" == true ]] && [[ "$HAS_GIT" == true ]]; then
32+
LATEST_VERSION="$(helpers::get_latest_tag)"
33+
else
34+
LATEST_VERSION="${BASHUNIT_VERSION}"
35+
fi
3236
TEST_ENV_FILE="tests/acceptance/fixtures/.env.default"
3337
}
3438

0 commit comments

Comments
 (0)