Skip to content

Commit

Permalink
better condition
Browse files Browse the repository at this point in the history
  • Loading branch information
ipitio committed Apr 16, 2024
1 parent ea1d330 commit 392a8be
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions advanced/Scripts/speedtestmod/mod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,21 @@ download() {
git reset --hard origin/"$branch" -q
git checkout -B "$branch" -q
local currentVersion=$(getVersion "$dest")
[[ "$currentVersion" != *.* ]] || currentVersion=$(git ls-remote -t "$url" | grep $currentVersion$ | awk '{print $1;}')
local tags=$(git ls-remote -t "$url")
[[ "$currentVersion" != *.* ]] || currentVersion=$(echo "$tags" | grep $currentVersion$ | awk '{print $1;}')

if [ -z "$desiredVersion" ]; then # if empty, get the latest version
if [ "$snapToTag" == "true" ]; then
local latestTag=$(git ls-remote -t "$url" | awk -F/ '{print $3}' | grep '^v[0-9]' | grep -v '\^{}' | sort -V | tail -n1)
local latestTag=$(echo "$tags" | awk -F/ '{print $3}' | grep '^v[0-9]' | grep -v '\^{}' | sort -V | tail -n1)
[ ! -z "$latestTag" ] && desiredVersion=$latestTag || desiredVersion=$currentVersion
fi
elif $aborting; then
desiredVersion=$(getVersion "$desiredVersion")
fi

[[ "$desiredVersion" != *.* ]] || desiredVersion=$(git ls-remote -t "$url" | grep $desiredVersion$ | awk '{print $1;}')
[[ "$desiredVersion" != *.* ]] || desiredVersion=$(echo "$tags" | grep $desiredVersion$ | awk '{print $1;}')

if [ "$currentVersion" != "$desiredVersion" ]; then
if [ ! -z "$desiredVersion" ] && [ "$currentVersion" != "$desiredVersion" ]; then
git fetch origin --depth=1 $desiredVersion -q
git -c advice.detachedHead=false checkout $desiredVersion -q
fi
Expand Down

0 comments on commit 392a8be

Please sign in to comment.