From 739ad5f31a3cf98db5df5b908865e6d1915c4062 Mon Sep 17 00:00:00 2001 From: Malik Baktiyarov Date: Thu, 10 Sep 2015 16:17:37 +0300 Subject: [PATCH 1/2] fix match server: different ports --- lib/capistrano/configuration/server.rb | 2 +- lib/capistrano/configuration/servers.rb | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/capistrano/configuration/server.rb b/lib/capistrano/configuration/server.rb index 74c6a586..748b052b 100644 --- a/lib/capistrano/configuration/server.rb +++ b/lib/capistrano/configuration/server.rb @@ -62,7 +62,7 @@ module Capistrano end def matches?(other) - hostname == other.hostname + hostname == other.hostname && port == other.port end private diff --git a/lib/capistrano/configuration/servers.rb b/lib/capistrano/configuration/servers.rb index 8cc4ee4c..aa458d55 100644 --- a/lib/capistrano/configuration/servers.rb +++ b/lib/capistrano/configuration/servers.rb @@ -11,7 +11,6 @@ module Capistrano new_host = Server[host] if (server = servers.find { |s| s.matches? new_host }) server.user = new_host.user if new_host.user - server.port = new_host.port if new_host.port server.with(properties) else servers << new_host.with(properties) From 7e8e2392c62b887dcf10a61a2bb2fed8cd54b180 Mon Sep 17 00:00:00 2001 From: Malik Baktiyarov Date: Thu, 10 Sep 2015 18:09:23 +0300 Subject: [PATCH 2/2] spec: match server different ports --- spec/integration/dsl_spec.rb | 14 ++++++++------ spec/lib/capistrano/configuration/servers_spec.rb | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/spec/integration/dsl_spec.rb b/spec/integration/dsl_spec.rb index 92e12d01..000ce33e 100644 --- a/spec/integration/dsl_spec.rb +++ b/spec/integration/dsl_spec.rb @@ -273,22 +273,24 @@ describe Capistrano::DSL do end describe 'fetching all servers' do - it 'creates one server per hostname, ignoring user and port combinations' do - expect(dsl.roles(:all).size).to eq(1) + it 'creates one server per hostname, ignoring user combinations' do + expect(dsl.roles(:all).size).to eq(2) end end describe 'fetching servers for a role' do it 'roles defined using the `server` syntax are included' do as = dsl.roles(:web).map { |server| "#{server.user}@#{server.hostname}:#{server.port}" } - expect(as.size).to eq(1) - expect(as[0]).to eq("deployer@example1.com:5678") + expect(as.size).to eq(2) + expect(as[0]).to eq("deployer@example1.com:1234") + expect(as[1]).to eq("@example1.com:5678") end it 'roles defined using the `role` syntax are included' do as = dsl.roles(:app).map { |server| "#{server.user}@#{server.hostname}:#{server.port}" } - expect(as.size).to eq(1) - expect(as[0]).to eq("deployer@example1.com:5678") + expect(as.size).to eq(2) + expect(as[0]).to eq("deployer@example1.com:1234") + expect(as[1]).to eq("@example1.com:5678") end end diff --git a/spec/lib/capistrano/configuration/servers_spec.rb b/spec/lib/capistrano/configuration/servers_spec.rb index 6582524f..ef54b35e 100644 --- a/spec/lib/capistrano/configuration/servers_spec.rb +++ b/spec/lib/capistrano/configuration/servers_spec.rb @@ -140,7 +140,7 @@ module Capistrano servers.add_host('1', roles: [:app, 'web'], test: :value, user: 'root', port: 34) servers.add_host('1', roles: [:app, 'web'], test: :value, user: 'deployer', port: 34) servers.add_host('1', roles: [:app, 'web'], test: :value, user: 'deployer', port: 56) - expect(servers.count).to eq(1) + expect(servers.count).to eq(5) end describe "with a :user property" do