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

View File

@ -2,20 +2,19 @@
plugin_update_command() { plugin_update_command() {
if [ "$#" -lt 1 ]; then 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 exit 1
fi fi
local plugin_name="$1" local plugin_name="$1"
local gitref="${2:-master}" local gitref="${2}"
if [ "$plugin_name" = "--all" ]; then if [ "$plugin_name" = "--all" ]; then
if [ -d "$(asdf_data_dir)"/plugins ]; then if [ -d "$(asdf_data_dir)"/plugins ]; then
plugins=(find "$(asdf_data_dir)"/plugins -type d -mindepth 1 -maxdepth 1) plugins=(find "$(asdf_data_dir)"/plugins -mindepth 1 -maxdepth 1 -type d)
while IFS= read -r -d '' dir; do while IFS= read -r dir; do
local plugin_name update_plugin "$(basename "$dir")" "$dir" "$gitref" &
plugin_name=$(basename "$dir") done <<<"$plugins"
update_plugin "$plugin_name" "$dir" "$gitref" &
done <<< "$plugins"
wait wait
fi fi
else else
@ -29,11 +28,13 @@ plugin_update_command() {
update_plugin() { update_plugin() {
local plugin_name=$1 local plugin_name=$1
local plugin_path=$2 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) logfile=$(mktemp)
{ {
printf "Updating %s...\\n" "$plugin_name" printf "Updating %s to %s\\n" "$plugin_name" "$gitref"
(cd "$plugin_path" && git fetch -p -u origin "$gitref:$gitref" && git checkout -f "$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 } >"$logfile" 2>&1
cat "$logfile" cat "$logfile"
rm "$logfile" rm "$logfile"