helpers: goenv is broken when checking out latest master commit.

Instead, checkout the latest commit. Same for xxenv-latest.
This commit is contained in:
Salamandar 2024-06-03 11:55:40 +02:00
parent d77b646971
commit e6b676df5b

View file

@ -111,43 +111,35 @@ ynh_install_go () {
test -x /usr/bin/go && mv /usr/bin/go /usr/bin/go_goenv test -x /usr/bin/go && mv /usr/bin/go /usr/bin/go_goenv
# Install or update goenv # Install or update goenv
goenv="$(command -v goenv $goenv_install_dir/bin/goenv | head -1)" mkdir -p $goenv_install_dir
if [ -n "$goenv" ]; then pushd "$goenv_install_dir"
ynh_print_info --message="goenv already seems installed in \`$goenv'." if ! [ -x "$goenv_install_dir/bin/goenv" ]; then
pushd "${goenv%/*/*}" ynh_print_info --message="Downloading goenv..."
if git remote -v 2>/dev/null | grep "https://github.com/syndbg/goenv.git"; then
echo "Trying to update with Git..."
git pull -q --tags origin master
cd ..
ynh_go_try_bash_extension
fi
popd
else
ynh_print_info --message="Installing goenv with Git..."
mkdir -p $goenv_install_dir
pushd $goenv_install_dir
git init -q git init -q
git remote add -f -t master origin https://github.com/syndbg/goenv.git > /dev/null 2>&1 git remote add origin https://github.com/syndbg/goenv.git
git checkout -q -b master origin/master else
ynh_go_try_bash_extension ynh_print_info --message="Updating goenv..."
goenv=$goenv_install_dir/bin/goenv fi
popd git fetch -q --tags --prune origin
fi local git_latest_tag=$(git describe --tags "$(git rev-list --tags --max-count=1)")
git checkout -q "$git_latest_tag"
ynh_go_try_bash_extension
goenv=$goenv_install_dir/bin/goenv
popd
goenv_latest="$(command -v "$goenv_install_dir"/plugins/*/bin/goenv-latest goenv-latest | head -1)" # Install or update xxenv-latest
if [ -n "$goenv_latest" ]; then mkdir -p "$goenv_install_dir/plugins/xxenv-latest"
ynh_print_info --message="\`goenv latest' command already available in \`$goenv_latest'." pushd "$goenv_install_dir/plugins/xxenv-latest"
pushd "${goenv_latest%/*/*}" if ! [ -x "$goenv_install_dir/plugins/xxenv-latest/bin/goenv-latest" ]; then
if git remote -v 2>/dev/null | grep "https://github.com/momo-lab/xxenv-latest.git"; then ynh_print_info --message="Downloading xxenv-latest..."
ynh_print_info --message="Trying to update xxenv-latest with git..." git init -q
git pull -q origin master git remote add origin https://github.com/momo-lab/xxenv-latest.git
fi else
popd ynh_print_info --message="Updating xxenv-latest..."
else fi
ynh_print_info --message="Installing xxenv-latest with Git..." local git_latest_tag=$(git describe --tags "$(git rev-list --tags --max-count=1)")
mkdir -p "${goenv_install_dir}/plugins" git checkout -q "$git_latest_tag"
git clone -q https://github.com/momo-lab/xxenv-latest.git "${goenv_install_dir}/plugins/xxenv-latest" popd
fi
# Enable caching # Enable caching
mkdir -p "${goenv_install_dir}/cache" mkdir -p "${goenv_install_dir}/cache"
@ -224,7 +216,7 @@ ynh_cleanup_go () {
required_go_versions="${installed_app_go_version}\n${required_go_versions}" required_go_versions="${installed_app_go_version}\n${required_go_versions}"
fi fi
done done
# Remove no more needed Go versions # Remove no more needed Go versions
local installed_go_versions=$(goenv versions --bare --skip-aliases | grep -Ev '/') local installed_go_versions=$(goenv versions --bare --skip-aliases | grep -Ev '/')
for installed_go_version in $installed_go_versions for installed_go_version in $installed_go_versions