Skip to content
This repository has been archived by the owner on Sep 1, 2020. It is now read-only.

Commit

Permalink
Merge pull request #79 from reednj/reednj/home-path
Browse files Browse the repository at this point in the history
handle ssh urls that use home relative paths (ie. paths starting with ~)
  • Loading branch information
mislav committed Mar 22, 2019
2 parents c40210b + bdd8cbc commit fe10add
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
sudo: false
bundler_args: "--without development"
script: bundle exec rspec
rvm:
Expand Down
11 changes: 10 additions & 1 deletion lib/git_deploy/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,16 @@ module Configuration
extend Forwardable
def_delegator :remote_url, :host
def_delegator :remote_url, :port, :remote_port
def_delegator :remote_url, :path, :deploy_to

def deploy_to
@deploy_to ||= begin
if remote_url.path.start_with? '/~/'
remote_url.path[1..-1]
else
remote_url.path
end
end
end

def remote_user
@user ||= begin
Expand Down
9 changes: 9 additions & 0 deletions spec/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ def stub_remote_url(url, remote = options[:remote])
its(:deploy_to) { should eq('/path/to/app') }
end

context "scp-style with home" do
before { stub_remote_url 'git@example.com:~/path/to/app' }

its(:host) { should eq('example.com') }
its(:remote_port) { should be_nil }
its(:remote_user) { should eq('git') }
its(:deploy_to) { should eq('~/path/to/app') }
end

context "pushurl only" do
before {
remote = options.fetch(:remote)
Expand Down

0 comments on commit fe10add

Please sign in to comment.