Repurpose as disable flag instead of customization

This commit is contained in:
Jonathan Beverly 2022-06-23 00:36:23 +00:00
parent a3f251477b
commit 4a54c4529d
5 changed files with 22 additions and 14 deletions

View File

@ -1,3 +1,2 @@
# 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

@ -57,7 +57,7 @@ legacy_version_file = no
use_release_candidates = no
always_keep_download = no
plugin_repository_last_check_duration = 60
asdf_repository_url = https://github.com/asdf-vm/asdf-plugins.git
disable_short_name_repository = yes
```
### `legacy_version_file`
@ -97,13 +97,13 @@ Configure the duration since the last asdf plugin repository sync to the next. C
| `0` | Sync on each trigger event |
| `never` | Never sync |
### `asdf_repository_url`
### `disable_short_name_repository`
::: warning Note
Custom short-name plugin repositories are not supported
Existing plugins available from the short-name repository will continue to be installable.
:::
Configure the url of the short-name repository. Commands `asdf plugin add <name>` or `asdf plugin list all` will trigger a clone of the repository, if a value is set.
Disable installing or updating the short-name repository. Commands `asdf plugin add <name>` or `asdf plugin list all` will fail if no short-name repository has been configured.
| Options | Description |
| :------------------------------------------------------------------------------------------------------ | :----------------------------------------------------------- |

View File

@ -75,7 +75,7 @@ Removing a plugin will remove all installations of the tool made with the plugin
## Syncing the Short-name Repository
::: tip Recommendation
The short-name repo can be disabled by removing `asdf_repository_url` from the default configuration file.
The short-name repo can be disabled using the flag `disable_short_name_repository`.
:::
The short-name repo is synced to your local machine and periodically refreshed. This period is determined by the following method:

View File

@ -32,6 +32,10 @@ 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
@ -400,11 +404,13 @@ initialize_or_update_repository() {
local repository_url
local repository_path
repository_url="$(get_asdf_config_value "asdf_repository_url")"
if [ -z "$repository_url" ]; then
printf "No short-name plugin repository in configuration\\n" >&2
disable_short_name_repo="$(get_asdf_config_value "disable_short_name_repository")"
if [ "yes" == "$disable_short_name_repo" ]; then
printf "Short-name plugin repository is disabled\\n" >&2
exit 1
fi
repository_url=$(asdf_repository_url)
repository_path=$(asdf_data_dir)/repository
if [ ! -d "$repository_path" ]; then

View File

@ -41,15 +41,16 @@ teardown() {
[ "$output" = "elixir" ]
}
@test "plugin_add command with no URL specified adds a plugin using repo from config" {
@test "plugin_add command with no URL specified adds a plugin when short name repository is enabled" {
export ASDF_CONFIG_DEFAULT_FILE=$BATS_TMPDIR/asdfrc_defaults
echo "" > $ASDF_CONFIG_DEFAULT_FILE
export ASDF_CONFIG_FILE=$BATS_TMPDIR/asdfrc
cat > $ASDF_CONFIG_FILE <<-EOM
asdf_repository_url = https://github.com/asdf-vm/asdf-plugins.git
disable_short_name_repository=no
EOM
run asdf plugin add "elixir"
[ "$status" -eq 0 ]
@ -58,16 +59,18 @@ EOM
[ "$output" = "elixir" ]
}
@test "plugin_add command with no URL specified fails to add a plugin when no default repo" {
@test "plugin_add command with no URL specified fails to add a plugin when disabled" {
export ASDF_CONFIG_DEFAULT_FILE=$BATS_TMPDIR/asdfrc_defaults
echo "" > $ASDF_CONFIG_DEFAULT_FILE
export ASDF_CONFIG_FILE=$BATS_TMPDIR/asdfrc
echo "" > $ASDF_CONFIG_FILE
cat > $ASDF_CONFIG_FILE <<-EOM
disable_short_name_repository=yes
EOM
run asdf plugin add "elixir"
[ "$status" -eq 1 ]
[ "$output" = "No short-name plugin repository in configuration" ]
[ "$output" = "Short-name plugin repository is disabled" ]
}
@test "plugin_add command with URL specified adds a plugin using repo" {