Skip to content

Commit 58bba5b

Browse files
authored
Merge pull request #2 from codeur/fix-asdf-version-usage
Fix ASDF version usage
2 parents bf3b1f5 + 3bb1933 commit 58bba5b

5 files changed

Lines changed: 38 additions & 42 deletions

File tree

.github/workflows/test.yml

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,13 @@ on:
1010
jobs:
1111
build:
1212
runs-on: ubuntu-latest
13-
name: Ruby ${{ matrix.ruby }}
14-
strategy:
15-
matrix:
16-
ruby:
17-
- '3.3.4'
13+
name: Test and lint
1814

1915
steps:
20-
- uses: actions/checkout@v4
21-
- name: Set up Ruby
22-
uses: ruby/setup-ruby@v1
23-
with:
24-
ruby-version: ${{ matrix.ruby }}
25-
bundler-cache: true
26-
- name: Run the default task
27-
run: bundle exec rake
16+
- uses: actions/checkout@v4
17+
- name: Set up Ruby
18+
uses: ruby/setup-ruby@v1
19+
with:
20+
bundler-cache: true
21+
- name: Run the default task
22+
run: bundle exec rake

.tool-versions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ruby 3.3.6

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 1.5.2
4+
5+
Make ASDF version really usable with `asdf_version` variable.
6+
37
## 1.5.1
48

59
Remove update of ASDF which has been removed. See https://github.com/asdf-vm/asdf/pull/1806.

lib/capistrano/asdf/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
module Capistrano
44
module Asdf
5-
VERSION = "1.5.1"
5+
VERSION = "1.5.2"
66
end
77
end

lib/capistrano/tasks/asdf.rake

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,18 @@ namespace :asdf do
2424
if fetch(:asdf_setup)
2525
on roles(fetch(:asdf_roles)) do
2626
if test("[ -d #{fetch(:asdf_path)} ]")
27-
info "ASDF is installed on #{fetch(:asdf_path)}"
27+
within(fetch(:asdf_path)) do
28+
version = capture(:cat, "version.txt").strip
29+
if fetch(:asdf_version) == version
30+
info "ASDF #{fetch(:asdf_version)} is already installed on #{fetch(:asdf_path)}"
31+
else
32+
execute :git, "checkout", "v#{fetch(:asdf_version)}"
33+
info "ASDF is updated from #{version} to #{fetch(:asdf_version)} (on #{fetch(:asdf_path)})"
34+
end
35+
end
2836
else
2937
execute(:git, "clone", fetch(:asdf_repository), fetch(:asdf_path), "--branch", fetch(:asdf_version))
38+
info "ASDF #{fetch(:asdf_version)} is installed on #{fetch(:asdf_path)}"
3039
end
3140
end
3241
end
@@ -61,20 +70,13 @@ namespace :asdf do
6170
end
6271

6372
namespace :uninstall do
64-
desc "Uninstall ASDF Ruby version based on the .tool-versions of your project"
65-
task :ruby do
66-
on roles(fetch(:asdf_roles)) do
67-
within(release_path) do
68-
execute(:asdf, "uninstall", "ruby")
69-
end
70-
end
71-
end
72-
73-
desc "Uninstall ASDF NodeJS version based on the .tool-versions of your project"
74-
task :nodejs do
75-
on roles(fetch(:asdf_roles)) do
76-
within(release_path) do
77-
execute(:asdf, "uninstall", "nodejs")
73+
%i[ruby nodejs].each do |tool|
74+
desc "Uninstall ASDF #{tool} version based on the .tool-versions of your project"
75+
task tool do
76+
on roles(fetch(:asdf_roles)) do
77+
within(release_path) do
78+
execute(:asdf, "uninstall", tool.to_s)
79+
end
7880
end
7981
end
8082
end
@@ -87,22 +89,16 @@ namespace :asdf do
8789
asdf_prefix = fetch(:asdf_prefix, -> { "#{fetch(:asdf_path)}/bin/asdf exec" })
8890
SSHKit.config.command_map[:asdf] = "#{fetch(:asdf_path)}/bin/asdf"
8991

90-
if fetch(:asdf_tools).include?("ruby")
91-
if fetch(:asdf_ruby_use_jemalloc)
92-
on roles(fetch(:asdf_roles)) do
93-
if test("[ -f #{fetch(:asdf_jemalloc_path)}/jemalloc.h ]")
94-
SSHKit.config.default_env.merge!(ruby_configure_opts: "--with-jemalloc=#{fetch(:asdf_jemalloc_path)}")
95-
end
92+
if fetch(:asdf_tools).include?("ruby") && fetch(:asdf_ruby_use_jemalloc)
93+
on roles(fetch(:asdf_roles)) do
94+
if test("[ -f #{fetch(:asdf_jemalloc_path)}/jemalloc.h ]")
95+
SSHKit.config.default_env.merge!(ruby_configure_opts: "--with-jemalloc=#{fetch(:asdf_jemalloc_path)}")
9696
end
9797
end
98-
99-
fetch(:asdf_map_ruby_bins).uniq.each do |command|
100-
SSHKit.config.command_map.prefix[command.to_sym].unshift(asdf_prefix)
101-
end
10298
end
10399

104-
if fetch(:asdf_tools).include?("nodejs")
105-
fetch(:asdf_map_nodejs_bins).uniq.each do |command|
100+
fetch(:asdf_tools).each do |tool|
101+
fetch(:"asdf_map_#{tool}_bins", []).uniq.each do |command|
106102
SSHKit.config.command_map.prefix[command.to_sym].unshift(asdf_prefix)
107103
end
108104
end
@@ -119,7 +115,7 @@ namespace :load do
119115
task :defaults do
120116
set :asdf_path, fetch(:asdf_path, "~/.asdf")
121117
set :asdf_repository, fetch(:asdf_repository, "https://github.com/asdf-vm/asdf.git")
122-
set :asdf_version, fetch(:asdf_version, "v0.14.1")
118+
set :asdf_version, fetch(:asdf_version, "0.15.0")
123119
set :asdf_setup, fetch(:asdf_setup, true)
124120
set :asdf_roles, fetch(:asdf_roles, :all)
125121
set :asdf_ruby_use_jemalloc, fetch(:asdf_ruby_use_jemalloc, true)

0 commit comments

Comments
 (0)