mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 01:28:17 -07:00
fix: also fix bug with cleaning up old versions
It had a similiar issue with removing plugins based on the prefix and not the full version string.
This commit is contained in:
parent
e5863f3701
commit
4e9d04ccaa
@ -120,7 +120,7 @@ remove_obsolete_shims() {
|
||||
obsolete_shims=$(comm -23 <(echo "$shims") <(echo "$exec_names"))
|
||||
|
||||
for shim_name in $obsolete_shims; do
|
||||
remove_shim_for_version "$plugin_name" "$version" "$shim_name"
|
||||
remove_shim_for_version "$plugin_name" "$full_version" "$shim_name"
|
||||
done
|
||||
}
|
||||
|
||||
@ -137,11 +137,11 @@ remove_shim_for_version() {
|
||||
local count_installed
|
||||
count_installed=$(list_installed_versions "$plugin_name" | wc -l)
|
||||
|
||||
if ! grep "# asdf-plugin: $plugin_name $version" "$shim_path" > /dev/null 2>&1; then
|
||||
if ! grep -x "# asdf-plugin: $plugin_name $version" "$shim_path" > /dev/null 2>&1; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
sed -i.bak -e "/# asdf-plugin: $plugin_name $version/d" "$shim_path"
|
||||
sed -i.bak -e "/# asdf-plugin: $plugin_name $version"'$/d' "$shim_path"
|
||||
rm "$shim_path".bak
|
||||
|
||||
if ! grep "# asdf-plugin:" "$shim_path" > /dev/null || \
|
||||
@ -154,6 +154,6 @@ remove_shims_for_version() {
|
||||
local plugin_name=$1
|
||||
local full_version=$2
|
||||
for shim_path in $(plugin_shims "$plugin_name" "$full_version"); do
|
||||
remove_shim_for_version "$plugin_name" "$version" "$shim_path"
|
||||
remove_shim_for_version "$plugin_name" "$full_version" "$shim_path"
|
||||
done
|
||||
}
|
||||
|
@ -545,7 +545,7 @@ is_executable() {
|
||||
plugin_shims() {
|
||||
local plugin_name=$1
|
||||
local full_version=$2
|
||||
grep -l "# asdf-plugin: $plugin_name $full_version" "$(asdf_data_dir)/shims"/* 2>/dev/null
|
||||
grep -lx "# asdf-plugin: $plugin_name $full_version" "$(asdf_data_dir)/shims"/* 2>/dev/null
|
||||
}
|
||||
|
||||
shim_plugin_versions() {
|
||||
|
@ -57,6 +57,17 @@ teardown() {
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "reshim should not remove metadata of removed prefix versions" {
|
||||
run asdf install dummy 1.0
|
||||
run asdf install dummy 1.0.1
|
||||
run rm "$ASDF_DIR/installs/dummy/1.0/bin/dummy"
|
||||
run asdf reshim dummy
|
||||
[ "$status" -eq 0 ]
|
||||
[ -f "$ASDF_DIR/shims/dummy" ]
|
||||
run grep "asdf-plugin: dummy 1.0.1" "$ASDF_DIR/shims/dummy"
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "reshim should not duplicate shims" {
|
||||
cd $PROJECT_DIR
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user