Skip to content

Commit

Permalink
Merge branch 'master' into ban-process-substitution
Browse files Browse the repository at this point in the history
  • Loading branch information
jthegedus committed Apr 27, 2021
2 parents 43d6fef + ad6b86f commit 10d9c12
Show file tree
Hide file tree
Showing 21 changed files with 166 additions and 48 deletions.
8 changes: 6 additions & 2 deletions CONTRIBUTING.md
Expand Up @@ -20,13 +20,17 @@ details like asdf version, shell, OS, etc...
## Did you write a patch that fixes a bug?

Open a new GitHub pull request with the patch. Refer to the [Development
section of the README](http://asdf-vm.github.io/asdf/#/contributing-core-asdf-vm) for the
section of the README](http://asdf-vm.github.io/asdf/#/contributing-core-asdf) for the
details on how to run the unit tests. Please make sure that unit tests pass on
Travis CI.

Pull request must contain changes that add new features, fix bugs, or fix
incorrect documentation. Unsolicited pull requests that only contain formatting
changes like indentation, or line length, or letter case will be rejected.

## Did you create a plugin for asdf?

Please read the [creating plugins](docs/creating-plugins.md) guide.
Please read the [creating plugins](docs/plugins-create.md) guide.

## Do you want to contribute the asdf documentation?

Expand Down
9 changes: 4 additions & 5 deletions README.md
Expand Up @@ -17,7 +17,7 @@ asdf is a CLI tool that can manage multiple language runtime versions on a per-p

## Documentation

[Please head over the documentation site for more information](https://asdf-vm.github.io/asdf/)!
[Please head over to the documentation site for more information](https://asdf-vm.github.io/asdf/)!

- [Getting Started](https://asdf-vm.github.io/asdf/#/core-manage-asdf)
- [All Commands](https://asdf-vm.github.io/asdf/#/core-commands)
Expand All @@ -27,11 +27,10 @@ asdf is a CLI tool that can manage multiple language runtime versions on a per-p

## Contributing

See [CONTRIBUTING.md in the repo](https://github.com/asdf-vm/asdf/blob/master/CONTRIBUTING.md) or the [Contributing section on the docs site](http://asdf-vm.github.io/asdf/#/contributing-core-asdf-vm).
See [CONTRIBUTING.md in the repo](https://github.com/asdf-vm/asdf/blob/master/CONTRIBUTING.md) or the [Contributing section on the docs site](http://asdf-vm.github.io/asdf/#/contributing-core-asdf).

## Community & Questions

<!-- - [![GitHub Discussions](https://icongram.jgog.in/simple/github.svg?color=808080&size=16)Github Discussions TBA](https://github.com/asdf-vm/asdf/discussions): our preferred method for community Q&A and interaction -->

- [![Github Issues](https://icongram.jgog.in/simple/github.svg?color=808080&size=16) Github Issues](https://github.com/asdf-vm/asdf/issues): report a bug or raise a feature request to the `asdf` core team
- [![GitHub Issues](https://icongr.am/simple/github.svg?color=808080&size=16) GitHub Issues](https://github.com/asdf-vm/asdf/issues): report a bug or raise a feature request to the `asdf` core team
- [![GitHub Discussions](https://icongr.am/simple/github.svg?color=808080&size=16) GitHub Discussions](https://github.com/asdf-vm/asdf/discussions): our preferred method for community Q&A and interaction
- [![StackOverflow Tag](https://icongr.am/fontawesome/stack-overflow.svg?size=16&color=808080) StackOverflow Tag](https://stackoverflow.com/questions/tagged/asdf-vm): see existing Q&A for `asdf`. Some of the core team watch this tag in addition to our helpful community
4 changes: 3 additions & 1 deletion SECURITY.md
Expand Up @@ -12,7 +12,8 @@ updating to the latest version of asdf will be required.

| Version | Supported |
| ------- | ------------------ |
| 0.7.x | :white_check_mark: |
| 0.8.x | :white_check_mark: |
| 0.7.x | :x: |
| 0.6.x | :x: |
| 0.5.x | :x: |
| 0.4.x | :x: |
Expand All @@ -26,4 +27,5 @@ To report a vulnerability please contact one of:

* @Stratus3D via email: see https://stratus3d.com/contact/ for email. PGP is not setup for this email address.
* @danhper via email: see https://daniel.perez.sh/ for email and PGP key
* @jthegedus via email: see https://github.com/jthegedus for email. PGP is not setup for this email address.
* TODO: Add secure contact methods of others on the core team.
21 changes: 20 additions & 1 deletion completions/_asdf
Expand Up @@ -76,6 +76,21 @@ _asdf__installed_versions_of() {
compadd -a versions
}

_asdf__installed_versions_of_plus_system() {
local plugin_dir="${asdf_dir:?}/installs/${1:?need a plugin version}"
if [[ ! -d "$plugin_dir" ]]; then
_wanted "asdf-versions-$1" expl "ASDF Plugin ${(q-)1} versions" \
compadd -x "no versions installed"
return
fi
local -a versions
versions=( "$plugin_dir"/*(:t) )
versions+="system"
_wanted "asdf-versions-$1" expl "ASDF Plugin ${(q-)1} versions" \
compadd -a versions
}


local -i IntermediateCount=0

if (( CURRENT == 2 )); then
Expand Down Expand Up @@ -165,10 +180,14 @@ case "$subcmd" in
compadd -- $(asdf list-all "$pkg" "$query")
fi
;;
(uninstall|shell|local|global|reshim)
(uninstall|reshim)
compset -n 2
_arguments '1:plugin-name: _asdf__installed_plugins' '2:package-version:{_asdf__installed_versions_of ${words[2]}}'
;;
(shell|local|global)
compset -n 2
_arguments '1:plugin-name: _asdf__installed_plugins' '2:package-version:{_asdf__installed_versions_of_plus_system ${words[2]}}'
;;
(where)
# version is optional
compset -n 2
Expand Down
14 changes: 13 additions & 1 deletion completions/asdf.bash
Expand Up @@ -44,7 +44,7 @@ _asdf() {
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "--head" -- "$cur"))
;;
uninstall | where | reshim | local | global | shell)
uninstall | where | reshim)
if [[ "$plugins" == *"$prev"* ]]; then
local versions
versions=$(asdf list "$prev" 2>/dev/null)
Expand All @@ -55,6 +55,18 @@ _asdf() {
COMPREPLY=($(compgen -W "$plugins" -- "$cur"))
fi
;;
local | global | shell)
if [[ "$plugins" == *"$prev"* ]]; then
local versions
versions=$(asdf list "$prev" 2>/dev/null)
versions+=" system"
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "$versions" -- "$cur"))
else
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "$plugins" -- "$cur"))
fi
;;
*)
local cmds='current global help install list list-all local plugin-add plugin-list plugin-list-all plugin-remove plugin-update reshim shell uninstall update where which info'
# shellcheck disable=SC2207
Expand Down
1 change: 1 addition & 0 deletions docs/_navbar.md
@@ -1,2 +1,3 @@
- Translations
- [:uk: English](/)
- [Add translation](contributing-doc-site?id=translations)
6 changes: 3 additions & 3 deletions docs/_sidebar.md
Expand Up @@ -15,6 +15,6 @@
- [Documentation Site](contributing-doc-site)
- [Thanks](thanks)
- **Community & Questions**
- [![Github Issues](https://icongram.jgog.in/simple/github.svg?color=808080&size=16)Github Issues](https://github.com/asdf-vm/asdf/issues)
- [![StackOverflow Tag](https://icongr.am/fontawesome/stack-overflow.svg?size=16&color=808080)StackOverflow Tag](https://stackoverflow.com/questions/tagged/asdf-vm)
<!-- - [![GitHub Discussions](https://icongram.jgog.in/simple/github.svg?color=808080&size=16)Github Discussions TBA](https://github.com/asdf-vm/asdf/discussions) -->
- [![GitHub Issues](https://icongr.am/simple/github.svg?color=808080&size=16) GitHub Issues](https://github.com/asdf-vm/asdf/issues)
- [![GitHub Discussions](https://icongr.am/simple/github.svg?color=808080&size=16) GitHub Discussions](https://github.com/asdf-vm/asdf/discussions)
- [![StackOverflow Tag](https://icongr.am/fontawesome/stack-overflow.svg?size=16&color=808080) StackOverflow Tag](https://stackoverflow.com/questions/tagged/asdf-vm)
2 changes: 1 addition & 1 deletion docs/contributing-core-asdf.md
Expand Up @@ -6,7 +6,7 @@ If you want to try out your changes without making change to your installed `asd

Tools we use:

- [bats](https://github.com/sstephenson/bats) for testing. Make sure
- [bats](https://github.com/bats-core/bats-core) for testing. Make sure
`bats test/` passes after you made your changes.
- [Shellcheck](https://github.com/koalaman/shellcheck) for static analysis of our shell scripts.

Expand Down
3 changes: 2 additions & 1 deletion docs/core-configuration.md
Expand Up @@ -49,5 +49,6 @@ legacy_version_file = yes
## Environment Variables

- `ASDF_CONFIG_FILE` - Defaults to `~/.asdfrc` as described above. Can be set to any location.
- `ASDF_DEFAULT_TOOL_VERSIONS_FILENAME` - The name of the file storing the tool names and versions. Defaults to `.tool-versions`. Can be any valid file name.
- `ASDF_DEFAULT_TOOL_VERSIONS_FILENAME` - The filename of the file storing the tool names and versions. Defaults to `.tool-versions`. Can be any valid filename. Typically you should not override the default value unless you know you want asdf to ignore `.tool-versions` files.
- `ASDF_DIR` - Defaults to `~/.asdf` - Location of the `asdf` scripts. If you install `asdf` to some other directory, set this to that directory. For example, if you are installing via the AUR, you should set this to `/opt/asdf-vm`.
- `ASDF_DATA_DIR` - Defaults to `~/.asdf` - Location where `asdf` install plugins, shims and installs. Can be set to any location before sourcing `asdf.sh` or `asdf.fish` mentioned in the section above.
8 changes: 5 additions & 3 deletions docs/core-manage-asdf.md
Expand Up @@ -121,7 +121,7 @@ source ~/.asdf/asdf.fish
?> Completions must be configured manually with the following command:

```shell
mkdir -p ~/.config/fish/completions; and cp ~/.asdf/completions/asdf.fish ~/.config/fish/completions
mkdir -p ~/.config/fish/completions; and ln -s ~/.asdf/completions/asdf.fish ~/.config/fish/completions
```

#### --Linux,ZSH,Git--
Expand Down Expand Up @@ -235,10 +235,12 @@ echo -e "\nsource "(brew --prefix asdf)"/asdf.fish" >> ~/.config/fish/config.fis
Add `asdf.sh` to your `~/.zshrc` with:

```shell
echo -e "\n. $(brew --prefix asdf)/asdf.sh" >> ~/.zshrc
echo -e "\n. $(brew --prefix asdf)/asdf.sh" >> ${ZDOTDIR:-~}/.zshrc
```
**OR** use a ZSH Framework plugin like [asdf for oh-my-zsh](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/asdf) which will source this script and setup completions.

?> Completions are configured by either a ZSH Framework `asdf` or will need to be [configured as per Homebrew's instructions](https://docs.brew.sh/Shell-Completion#configuring-completions-in-zsh). If you are using a ZSH Framework the associated asdf plugin may need to be updated to use the new ZSH completions properly via fpath. The Oh-My-ZSH asdf plugin is yet to be updated, see [ohmyzsh/ohmyzsh#8837](https://github.com/ohmyzsh/ohmyzsh/pull/8837).

?> Completions will need to be [configured as per Homebrew's instructions](https://docs.brew.sh/Shell-Completion#configuring-completions-in-zsh).

### --Docsify Select Default--

Expand Down
13 changes: 12 additions & 1 deletion docs/core-manage-versions.md
Expand Up @@ -84,6 +84,17 @@ The version format is the same supported by the `.tool-versions` file.
ASDF_ELIXIR_VERSION=1.4.0 mix test
```

## Fallback to System Version

To use the system version of tool `<name>` instead of an asdf managed version you can set the version for the tool to `system`.

Set system with either `global`, `local` or `shell` as outlined in [Set Current Version](#set-current-version) section above.

```shell
asdf local <name> system
# asdf local python system
```

## View Current Version

```shell
Expand Down Expand Up @@ -122,6 +133,6 @@ source $(asdf which ${PLUGIN})/../script.sh
source $(asdf where ${PLUGIN} $(asdf current ${PLUGIN}))/bin/script.sh
```

###### By-passing asdf shims.
### By-passing asdf shims

If for some reason you want to by-pass asdf shims or want your environment variables automatically set upon entering your project's directory, the [asdf-direnv](https://github.com/asdf-community/asdf-direnv) plugin can be helpful. Be sure to check its README for more details.
2 changes: 1 addition & 1 deletion docs/plugins-create.md
Expand Up @@ -217,7 +217,7 @@ asdf plugin test nodejs https://github.com/asdf-vm/asdf-nodejs.git node --versio

We strongly recommend you test your plugin on a CI environment and make sure it works on both Linux and OSX.

#### Example Github Action
#### Example GitHub Action

The [asdf-vm/actions](https://github.com/asdf-vm/actions) repo provides a GitHub Action for testing your plugins hosted on github.

Expand Down
11 changes: 8 additions & 3 deletions help.txt
Expand Up @@ -7,9 +7,10 @@ asdf plugin list [--urls] [--refs] List installed plugins. Optionally show
asdf plugin list all List plugins registered on asdf-plugins
repository with URLs
asdf plugin remove <name> Remove plugin and package versions
asdf plugin update <name> [<git-ref>] Update a plugin to latest commit or a
particular git-ref
asdf plugin update --all Update all plugins
asdf plugin update <name> [<git-ref>] Update a plugin to latest commit on
default branch or a particular git-ref
asdf plugin update --all Update all plugins to latest commit on
default branch


MANAGE PACKAGES
Expand Down Expand Up @@ -51,3 +52,7 @@ asdf shim-versions <command> List the plugins and versions that
provide a command
asdf update Update asdf to the latest stable release
asdf update --head Update asdf to the latest on the master branch

RESOURCES
GitHub: https://github.com/asdf-vm/asdf
Docs: https://asdf-vm.com
2 changes: 1 addition & 1 deletion lib/commands/command-list.bash
Expand Up @@ -14,7 +14,7 @@ list_command() {
display_installed_versions "$plugin_name"
done
else
printf "%s\\n" 'Oohes nooes ~! No plugins installed'
printf "%s\\n" 'No plugins installed'
fi
else
check_if_plugin_exists "$plugin_name"
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/command-plugin-list.bash
Expand Up @@ -45,7 +45,7 @@ plugin_list_command() {
done
) | awk '{ if (NF > 1) { printf("%-28s", $1) ; $1="" }; print $0}'
else
display_error 'Oohes nooes ~! No plugins installed'
display_error 'No plugins installed'
exit 1
fi
}
Expand Down
4 changes: 2 additions & 2 deletions release/README.md
Expand Up @@ -13,7 +13,7 @@ with the format `<next-version>-dev`).
2. Run the tests and the linter - `bats test` and `lint.sh`.
3. Run the release script. The new version must be in the format `0.0.0-rc0`.
For example: `release/tag.sh 0.0.0-rc0`.
4. If the release script succeeds, push to Github. Make sure to use the correct
4. If the release script succeeds, push to GitHub. Make sure to use the correct
remote to push to the official repository

## Tagging Releases
Expand All @@ -24,5 +24,5 @@ with the format `<next-version>-dev`).
2. Run the tests and the linter - `bats test` and `lint.sh`.
3. Run the release script. The new version must be in the format `0.0.0`. For
example: `release/tag.sh 0.0.0`.
4. If the release script succeeds, push to Github. Make sure to use the correct
4. If the release script succeeds, push to GitHub. Make sure to use the correct
remote to push to the official repository
3 changes: 2 additions & 1 deletion test/banned_commands.bats
Expand Up @@ -14,8 +14,9 @@ banned_commands=(
column
# does not work on alpine and should be grep -i either way
"grep.* -y"
# sort -V isn't supported everywhere
# sort --sort-version isn't supported everywhere
"sort.*-V"
"sort.*--sort-versions"
# echo isn't consistent across operating systems, and sometimes output can
# be confused with echo flags. printf does everything echo does and more.
echo
Expand Down
2 changes: 1 addition & 1 deletion test/current_command.bats 100644 → 100755
Expand Up @@ -127,7 +127,7 @@ foobar 1.0.0 $PROJECT_DIR/.tool-versions"

@test "with no plugins prints an error" {
clean_asdf_dir
expected="Oohes nooes ~! No plugins installed"
expected="No plugins installed"

run asdf current
[ "$status" -eq 0 ]
Expand Down
85 changes: 67 additions & 18 deletions test/plugin_update_command.bats
Expand Up @@ -3,32 +3,81 @@
load test_helpers

setup() {
BASE_DIR=$(mktemp -dt asdf.XXXX)
HOME=$BASE_DIR/home
ASDF_DIR=$HOME/.asdf
git clone -o local "$(dirname "$BATS_TEST_DIRNAME")" "$ASDF_DIR"
git --git-dir "$ASDF_DIR/.git" remote add origin https://github.com/asdf-vm/asdf.git
mkdir -p "$ASDF_DIR/plugins"
ASDF_BIN="$ASDF_DIR/bin"

# shellcheck disable=SC2031
PATH=$ASDF_BIN:$ASDF_DIR/shims:$PATH
install_dummy_plugin

PROJECT_DIR=$HOME/project
mkdir $PROJECT_DIR
setup_asdf_dir
install_mock_plugin_repo "dummy"
run asdf plugin-add "dummy" "${BASE_DIR}/repo-dummy"
}

teardown() {
clean_asdf_dir
}

@test "asdf plugin-update should pull latest master branch for plugin" {
@test "asdf plugin-update should pull latest default branch (refs/remotes/origin/HEAD) for plugin" {
run asdf plugin-update dummy
repo_head="$(git --git-dir "$ASDF_DIR/plugins/dummy/.git" --work-tree "$ASDF_DIR/plugins/dummy" rev-parse --abbrev-ref HEAD)"
[ "$status" -eq 0 ]
[[ "$output" =~ "Updating dummy..."* ]]
cd $ASDF_DIR/plugins/dummy
[ $(git rev-parse --abbrev-ref HEAD) = "master" ]
[[ "$output" =~ "Updating dummy to master"* ]]
[ "$repo_head" = "master" ]
}

@test "asdf plugin-update should pull latest default branch (refs/remotes/origin/HEAD) for plugin even if default branch changes" {
install_mock_plugin_repo "dummy-remote"
remote_dir="$BASE_DIR/repo-dummy-remote"
# set HEAD to refs/head/main in dummy-remote
git -C "${remote_dir}" checkout -b main
# track & fetch remote repo (dummy-remote) in plugin (dummy)
git --git-dir "$ASDF_DIR/plugins/dummy/.git" --work-tree "$ASDF_DIR/plugins/dummy" remote remove origin
git --git-dir "$ASDF_DIR/plugins/dummy/.git" --work-tree "$ASDF_DIR/plugins/dummy" remote add origin "$remote_dir"
git --git-dir "$ASDF_DIR/plugins/dummy/.git" --work-tree "$ASDF_DIR/plugins/dummy" fetch origin

run asdf plugin-update dummy
repo_head="$(git --git-dir "$ASDF_DIR/plugins/dummy/.git" --work-tree "$ASDF_DIR/plugins/dummy" rev-parse --abbrev-ref HEAD)"

[ "$status" -eq 0 ]
[[ "$output" =~ "Updating dummy to main"* ]]
[ "$repo_head" = "main" ]
}

@test "asdf plugin-update should pull latest default branch (refs/remotes/origin/HEAD) for plugin even if the default branch contains a forward slash" {
install_mock_plugin_repo "dummy-remote"
remote_dir="$BASE_DIR/repo-dummy-remote"
# set HEAD to refs/head/my/default in dummy-remote
git -C "${remote_dir}" checkout -b my/default
# track & fetch remote repo (dummy-remote) in plugin (dummy)
git --git-dir "$ASDF_DIR/plugins/dummy/.git" --work-tree "$ASDF_DIR/plugins/dummy" remote remove origin
git --git-dir "$ASDF_DIR/plugins/dummy/.git" --work-tree "$ASDF_DIR/plugins/dummy" remote add origin "$remote_dir"
git --git-dir "$ASDF_DIR/plugins/dummy/.git" --work-tree "$ASDF_DIR/plugins/dummy" fetch origin

run asdf plugin-update dummy
repo_head="$(git --git-dir "$ASDF_DIR/plugins/dummy/.git" --work-tree "$ASDF_DIR/plugins/dummy" rev-parse --abbrev-ref HEAD)"

[ "$status" -eq 0 ]
[[ "$output" =~ "Updating dummy to my/default"* ]]
[ "$repo_head" = "my/default" ]
}

@test "asdf plugin-update should pull latest default branch (refs/remotes/origin/HEAD) for plugin even if already set to specific ref" {
# set plugin to specific sha
current_sha="$(git --git-dir "${BASE_DIR}/repo-dummy/.git" --work-tree "$BASE_DIR/repo-dummy" rev-parse HEAD)"
run asdf plugin-update dummy "${current_sha}"

# setup mock plugin remote
install_mock_plugin_repo "dummy-remote"
remote_dir="$BASE_DIR/repo-dummy-remote"
# set HEAD to refs/head/main in dummy-remote
git -C "${remote_dir}" checkout -b main
# track & fetch remote repo (dummy-remote) in plugin (dummy)
git --git-dir "$ASDF_DIR/plugins/dummy/.git" --work-tree "$ASDF_DIR/plugins/dummy" remote remove origin
git --git-dir "$ASDF_DIR/plugins/dummy/.git" --work-tree "$ASDF_DIR/plugins/dummy" remote add origin "$remote_dir"
git --git-dir "$ASDF_DIR/plugins/dummy/.git" --work-tree "$ASDF_DIR/plugins/dummy" fetch origin

# update plugin to the default branch
run asdf plugin-update dummy
repo_head="$(git --git-dir "$ASDF_DIR/plugins/dummy/.git" --work-tree "$ASDF_DIR/plugins/dummy" rev-parse --abbrev-ref HEAD)"

[ "$status" -eq 0 ]
[[ "$output" =~ "Updating dummy to main"* ]]
[ "$repo_head" = "main" ]
}

@test "asdf plugin-update should not remove plugin versions" {
Expand Down

0 comments on commit 10d9c12

Please sign in to comment.