diff --git a/.travis.yml b/.travis.yml index 92dc677..8920d68 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ +sudo: false bundler_args: "--without development" script: bundle exec rspec rvm: - - 1.8.7 - - 1.9.3 - - 2.0.0 + - '2.3' + - '2.4' + - '2.5' diff --git a/Gemfile.lock b/Gemfile.lock index bc88868..5010f9d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,18 +1,18 @@ PATH remote: . specs: - git-deploy (0.6.0) - net-scp (~> 1.1.0) - net-ssh (~> 2.6.6) + git-deploy (0.6.1) + net-scp (~> 1.1) + net-ssh (~> 5.0) thor (= 0.14.6) GEM remote: https://rubygems.org/ specs: diff-lcs (1.2.4) - net-scp (1.1.2) + net-scp (1.2.1) net-ssh (>= 2.6.5) - net-ssh (2.6.8) + net-ssh (5.2.0) rspec (2.13.0) rspec-core (~> 2.13.0) rspec-expectations (~> 2.13.0) @@ -29,3 +29,6 @@ PLATFORMS DEPENDENCIES git-deploy! rspec (~> 2.13.0) + +BUNDLED WITH + 2.0.1 diff --git a/git-deploy.gemspec b/git-deploy.gemspec index 76a6c59..bd3e65e 100644 --- a/git-deploy.gemspec +++ b/git-deploy.gemspec @@ -1,12 +1,13 @@ # encoding: utf-8 Gem::Specification.new do |gem| gem.name = 'git-deploy' - gem.version = '0.6.1' + gem.version = '0.7.0' gem.executables = %w[ git-deploy ] gem.add_dependency 'thor', '0.14.6' - gem.add_dependency 'net-ssh', '~> 2.6.6' - gem.add_dependency 'net-scp', '~> 1.1.0' + gem.add_dependency 'net-ssh', '~> 5.0' + gem.add_dependency 'net-scp', '~> 1.1' + gem.required_ruby_version = '>= 2.2.6' gem.summary = "Simple git push-based application deployment" gem.description = "A tool to install useful git hooks on your remote repository to enable push-based, Heroku-like deployment on your host." diff --git a/lib/git_deploy/configuration.rb b/lib/git_deploy/configuration.rb index 25940bc..e9f653d 100644 --- a/lib/git_deploy/configuration.rb +++ b/lib/git_deploy/configuration.rb @@ -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 diff --git a/lib/git_deploy/ssh_methods.rb b/lib/git_deploy/ssh_methods.rb index 34afa6e..b2f345f 100644 --- a/lib/git_deploy/ssh_methods.rb +++ b/lib/git_deploy/ssh_methods.rb @@ -93,7 +93,7 @@ def scp_upload(files) def ssh_connection @ssh ||= begin - ssh = Net::SSH.start(host, remote_user, :port => remote_port) + ssh = Net::SSH.start(host, remote_user, :port => remote_port || 22) at_exit { ssh.close } ssh end diff --git a/lib/git_deploy/templates/before_restart.rb b/lib/git_deploy/templates/before_restart.rb index 61dc67c..e048768 100644 --- a/lib/git_deploy/templates/before_restart.rb +++ b/lib/git_deploy/templates/before_restart.rb @@ -21,7 +21,12 @@ def run(cmd) if File.file? 'Rakefile' tasks = [] - num_migrations = `git diff #{oldrev} #{newrev} --diff-filter=A --name-only -z -- db/migrate`.split("\0").size + if File.exist?('db/migrate') + num_migrations = `git diff #{oldrev} #{newrev} --diff-filter=A --name-only -z -- db/migrate`.split("\0").size + else + num_migrations = 0 + end + # run migrations if new ones have been added tasks << "db:migrate" if num_migrations > 0 diff --git a/spec/configuration_spec.rb b/spec/configuration_spec.rb index 5e46594..301609c 100644 --- a/spec/configuration_spec.rb +++ b/spec/configuration_spec.rb @@ -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)