Skip to content

Commit

Permalink
Merge pull request #411 from Fjan/restore-userdir-relative-path
Browse files Browse the repository at this point in the history
Restore ability to work with a relative path outside a `within` block
  • Loading branch information
mattbrictson authored Nov 18, 2017
2 parents 05a4322 + abfb3d6 commit 158c286
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!/download! relative to user dir that broke in #408 - [@Fjan](https://github.com/Fjan)

## [1.15.0][] (2017-11-03)

Expand Down
4 changes: 2 additions & 2 deletions lib/sshkit/backends/local.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/sshkit/backends/netssh.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ 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
end

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
Expand Down

0 comments on commit 158c286

Please sign in to comment.