Skip to content

Commit

Permalink
refactor: build_and_install_beta
Browse files Browse the repository at this point in the history
  • Loading branch information
Chemaclass committed Oct 12, 2024
1 parent e94ffe7 commit 89d605a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
21 changes: 10 additions & 11 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
#!/bin/bash
# shellcheck disable=SC2155
# shellcheck disable=SC2164
# shellcheck disable=SC2103

function check_git_is_installed() {
function build_and_install_beta() {
echo "> Downloading non-stable version: 'beta'"

if ! command -v git >/dev/null 2>&1; then
echo "Error: git is not installed." >&2
exit 1
fi
}

function build_and_install_beta() {
echo "> Downloading non-stable version: 'beta'"
git clone --depth 1 --no-tags $BASHUNIT_GIT_REPO temp_bashunit 2>/dev/null
cd temp_bashunit
./build.sh >/dev/null
local latest_commit
latest_commit=$(git rev-parse --short=8 HEAD)
local latest_commit=$(git rev-parse --short=7 HEAD)
# shellcheck disable=SC2103
cd ..

local beta_version
beta_version='(non-stable) beta after '"$LATEST_BASHUNIT_VERSION"' ['"$(date +'%Y-%m-%d')"'] 🐍 #'"$latest_commit"
local beta_version=$(printf "(non-stable) beta after %s [%s] 🐍 #%s" \
"$LATEST_BASHUNIT_VERSION" \
"$(date +'%Y-%m-%d')" \
"$latest_commit"
)

sed -i -e 's/BASHUNIT_VERSION=".*"/BASHUNIT_VERSION="'"$beta_version"'"/g' temp_bashunit/bin/bashunit
cp temp_bashunit/bin/bashunit ./
Expand Down Expand Up @@ -49,8 +50,6 @@ function install() {
######### MAIN ##########
#########################

check_git_is_installed

DIR=${1-lib}
VERSION=${2-latest}

Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/install_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function test_install_downloads_the_non_stable_beta_version() {
"$output"
assert_file_exists "$installed_bashunit"
assert_matches\
"$(printf "\(non-stable\) beta after ([0-9]+\.[0-9]+\.[0-9]+) \[2023-11-13\] 🐍 \#[a-fA-F0-9]{8}")"\
"$(printf "\(non-stable\) beta after ([0-9]+\.[0-9]+\.[0-9]+) \[2023-11-13\] 🐍 \#[a-fA-F0-9]{7}")"\
"$("$installed_bashunit" --env "$TEST_ENV_FILE" --version)"
assert_directory_not_exists "./deps/temp_bashunit"
file_count_of_deps_directory=$(find ./deps -mindepth 1 -maxdepth 1 -print | wc -l | tr -d ' ')
Expand Down

0 comments on commit 89d605a

Please sign in to comment.