chore: sync master

This commit is contained in:
jthegedus 2021-04-27 19:28:24 +10:00
parent 6af66dc88c
commit ade70b94db
2 changed files with 31 additions and 34 deletions

View File

@ -8,59 +8,55 @@ on:
paths-ignore:
- "**.md"
schedule:
- cron: "0 0 * * 5"
- cron: 0 0 * * 5
jobs:
test:
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
os:
- macos-latest
- ubuntu-latest
- windows-latest
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Fetch all tags
run: git fetch --depth 1 origin +refs/tags/*:refs/tags/*
with:
fetch-depth: 0
- name: Install dependencies on macOS
if: matrix.os == 'macos-latest'
run: |
brew install coreutils # needed by bats-core
brew install fish # for testing asdf.fish
if: runner.os == 'macOS'
run: brew install coreutils fish
- name: Install dependencies on Ubuntu
if: matrix.os == 'ubuntu-latest'
if: runner.os == 'Linux'
run: |
PPA="ppa:fish-shell/nightly-master"
sudo add-apt-repository -y "$PPA"
sudo apt-get update
sudo apt-get -y install fish
- name: Install bats-core on Windows
if: matrix.os == 'windows-latest'
run: npm install -g bats@1.1.0
- name: Install bats-core on Unix systems
if: matrix.os == 'macos-latest' || matrix.os == 'ubuntu-latest'
- name: Install bats-core
run: |
git clone --depth 1 --branch v1.1.0 https://github.com/bats-core/bats-core.git $HOME/bats-core
echo "::add-path::$HOME/bats-core/bin"
git clone --depth 1 --branch v1.2.1 https://github.com/bats-core/bats-core.git $HOME/bats-core
echo "$HOME/bats-core/bin" >>"$GITHUB_PATH"
- name: Run tests on Windows
if: matrix.os == 'windows-latest'
if: runner.os == 'Windows'
continue-on-error: true
run: bats test
env:
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
continue-on-error: true
GITHUB_API_TOKEN: ${{ github.token }}
- name: Run tests on Unix systems
if: matrix.os == 'macos-latest' || matrix.os == 'ubuntu-latest'
if: runner.os != 'Windows'
run: bats test
env:
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_API_TOKEN: ${{ github.token }}
lint:
runs-on: ubuntu-latest

View File

@ -2,20 +2,19 @@
plugin_update_command() {
if [ "$#" -lt 1 ]; then
display_error "usage: asdf plugin-update {<name> | --all} [git-ref]"
display_error "usage: asdf plugin-update {<name> [git-ref] | --all}"
exit 1
fi
local plugin_name="$1"
local gitref="${2:-master}"
local gitref="${2}"
if [ "$plugin_name" = "--all" ]; then
if [ -d "$(asdf_data_dir)"/plugins ]; then
plugins=(find "$(asdf_data_dir)"/plugins -type d -mindepth 1 -maxdepth 1)
while IFS= read -r -d '' dir; do
local plugin_name
plugin_name=$(basename "$dir")
update_plugin "$plugin_name" "$dir" "$gitref" &
done <<< "$plugins"
plugins=(find "$(asdf_data_dir)"/plugins -mindepth 1 -maxdepth 1 -type d)
while IFS= read -r dir; do
update_plugin "$(basename "$dir")" "$dir" "$gitref" &
done <<<"$plugins"
wait
fi
else
@ -29,11 +28,13 @@ plugin_update_command() {
update_plugin() {
local plugin_name=$1
local plugin_path=$2
local gitref=$3
plugin_remote_default_branch=$(git --git-dir "$plugin_path/.git" --work-tree "$plugin_path" ls-remote --symref origin HEAD | awk '{ sub(/refs\/heads\//, ""); print $2; exit }')
local gitref=${3:-${plugin_remote_default_branch}}
logfile=$(mktemp)
{
printf "Updating %s...\\n" "$plugin_name"
(cd "$plugin_path" && git fetch -p -u origin "$gitref:$gitref" && git checkout -f "$gitref")
printf "Updating %s to %s\\n" "$plugin_name" "$gitref"
git --git-dir "$plugin_path/.git" --work-tree "$plugin_path" fetch --prune --update-head-ok origin "$gitref:$gitref"
git --git-dir "$plugin_path/.git" --work-tree "$plugin_path" -c advice.detachedHead=false checkout --force "$gitref"
} >"$logfile" 2>&1
cat "$logfile"
rm "$logfile"