From 8208390418c7e591529830e0610fb72a1b68d7b1 Mon Sep 17 00:00:00 2001 From: "Jan M. Faber" Date: Sat, 18 Nov 2017 10:01:29 +0100 Subject: [PATCH 1/3] Restore ability to work with a relative path outside a `within` block --- lib/sshkit/backends/local.rb | 4 ++-- lib/sshkit/backends/netssh.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/sshkit/backends/local.rb b/lib/sshkit/backends/local.rb index f5fb4f9b..92d9ec2f 100644 --- a/lib/sshkit/backends/local.rb +++ b/lib/sshkit/backends/local.rb @@ -11,7 +11,7 @@ def initialize(_ = nil, &block) end def upload!(local, remote, options = {}) - remote = File.join(pwd_path, remote) unless remote.to_s.start_with?("/") + remote = File.join(pwd_path, remote) unless remote.to_s.start_with?("/") || pwd_path.nil? if local.is_a?(String) if options[:recursive] FileUtils.cp_r(local, remote) @@ -26,7 +26,7 @@ def upload!(local, remote, options = {}) end def download!(remote, local=nil, _options = {}) - remote = File.join(pwd_path, remote) unless remote.to_s.start_with?("/") + remote = File.join(pwd_path, remote) unless remote.to_s.start_with?("/") || pwd_path.nil? if local.nil? FileUtils.cp(remote, File.basename(remote)) else diff --git a/lib/sshkit/backends/netssh.rb b/lib/sshkit/backends/netssh.rb index a16a2c39..f7a3d7ab 100644 --- a/lib/sshkit/backends/netssh.rb +++ b/lib/sshkit/backends/netssh.rb @@ -63,7 +63,7 @@ def assign_defaults def upload!(local, remote, options = {}) summarizer = transfer_summarizer('Uploading', options) - remote = File.join(pwd_path, remote) unless remote.to_s.start_with?("/") + remote = File.join(pwd_path, remote) unless remote.to_s.start_with?("/") || pwd_path.nil? with_ssh do |ssh| ssh.scp.upload!(local, remote, options, &summarizer) end @@ -71,7 +71,7 @@ def upload!(local, remote, options = {}) def download!(remote, local=nil, options = {}) summarizer = transfer_summarizer('Downloading', options) - remote = File.join(pwd_path, remote) unless remote.to_s.start_with?("/") + remote = File.join(pwd_path, remote) unless remote.to_s.start_with?("/") || pwd_path.nil? with_ssh do |ssh| ssh.scp.download!(remote, local, options, &summarizer) end From 29795bb7c1e99f78608c80391c8b2f03027372ab Mon Sep 17 00:00:00 2001 From: "Jan M. Faber" Date: Sat, 18 Nov 2017 10:13:03 +0100 Subject: [PATCH 2/3] Restore ability to work with a relative path outside a `within` block --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ccf0a4c..8768ea47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ appear at the top. * Your contribution here! * [#410](https://github.com/capistrano/sshkit/pull/410): call #to_s on remote so Pathnames don't go :boom: - [@UnderpantsGnome](https://github.com/UnderpantsGnome) + * [#411](https://github.com/capistrano/sshkit/pull/410): fix upload!/dowbload! relative to user dir that broke in #408 - [@Fjan](https://github.com/Fjan) ## [1.15.0][] (2017-11-03) From abfb3d667da45c975afa19d15566ca8e337d582a Mon Sep 17 00:00:00 2001 From: "Jan M. Faber" Date: Sat, 18 Nov 2017 10:13:35 +0100 Subject: [PATCH 3/3] Restore ability to work with a relative path outside a `within` block --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8768ea47..59756d12 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ appear at the top. * Your contribution here! * [#410](https://github.com/capistrano/sshkit/pull/410): call #to_s on remote so Pathnames don't go :boom: - [@UnderpantsGnome](https://github.com/UnderpantsGnome) - * [#411](https://github.com/capistrano/sshkit/pull/410): fix upload!/dowbload! relative to user dir that broke in #408 - [@Fjan](https://github.com/Fjan) + * [#411](https://github.com/capistrano/sshkit/pull/410): fix upload!/download! relative to user dir that broke in #408 - [@Fjan](https://github.com/Fjan) ## [1.15.0][] (2017-11-03)