Support for disabling short-name repo

This commit is contained in:
Jonathan Beverly 2022-05-10 22:36:28 +00:00
parent 37046c7c64
commit 1ee0c62e51
3 changed files with 31 additions and 5 deletions

View File

@ -1,2 +1,3 @@
# enables the use of .ruby-version like files used by other version managers
legacy_version_file = no
asdf_repository_url = https://github.com/asdf-vm/asdf-plugins.git

View File

@ -32,10 +32,6 @@ asdf_dir() {
printf "%s\\n" "$ASDF_DIR"
}
asdf_repository_url() {
printf "https://github.com/asdf-vm/asdf-plugins.git\\n"
}
asdf_data_dir() {
local data_dir
@ -404,7 +400,11 @@ initialize_or_update_repository() {
local repository_url
local repository_path
repository_url=$(asdf_repository_url)
repository_url="$(get_asdf_config_value "asdf_repository_url")"
if [ ! -n "$repository_url" ]; then
printf "No short-name plugin repository in configuration\\n" >&2
exit 1
fi
repository_path=$(asdf_data_dir)/repository
if [ ! -d "$repository_path" ]; then

View File

@ -41,6 +41,31 @@ teardown() {
[ "$output" = "elixir" ]
}
@test "plugin_add command with no URL specified adds a plugin using repo from config" {
ASDF_CONFIG_FILE=$BATS_TMPDIR/asdfrc
cat > $ASDF_CONFIG_FILE <<-EOM
asdf_repository_url = "https://github.com/asdf-vm/asdf-plugins.git"
EOM
run asdf plugin add "elixir"
[ "$status" -eq 0 ]
run asdf plugin-list
# whitespace between 'elixir' and url is from printf %-15s %s format
[ "$output" = "elixir" ]
}
@test "plugin_add command with no URL specified fails to add a plugin when no default repo" {
ASDF_CONFIG_FILE=$BATS_TMPDIR/asdfrc
cat > $ASDF_CONFIG_FILE <<-EOM
# no asdf_repository_url for the tests
EOM
run asdf plugin add "elixir"
[ "$status" -eq 1 ]
[ "$output" = "No short-name plugin repository configured" ]
}
@test "plugin_add command with URL specified adds a plugin using repo" {
install_mock_plugin_repo "dummy"