1
0
Fork 0
mirror of https://github.com/capistrano/capistrano synced 2023-03-27 23:21:18 -04:00

Deduplicate list of linked directories

With this, we ensure to only handle each linked directory once.
Also, if a linked file is in a directory that is already being
handled, there is no need to link the same directory twice.

This should help to keep commands shorter, which might be an issue on
some shells. It certainly is easier on the eyes and logs.
This commit is contained in:
Matthias Viehweger 2015-11-04 22:09:04 +01:00
parent 44674031a6
commit b435060322
3 changed files with 20 additions and 6 deletions

View file

@ -28,6 +28,7 @@ https://github.com/capistrano/capistrano/compare/v3.4.0...HEAD
* Return first 12 characters (instead of 7) of SHA1 hash when determining current git revision (@sds)
* Clean up rubocop lint warnings (@cshaffer)
* Ensure task invocation within after hooks is namespace aware (@thickpaddy)
* Deduplicate list of linked directories
## `3.4.0`

View file

@ -96,7 +96,7 @@ module Capistrano
end
def map_dirnames(paths)
paths.map { |path| path.dirname }
paths.map { |path| path.dirname }.uniq
end
end
end

View file

@ -7,7 +7,7 @@ describe Capistrano::DSL::Paths do
let(:paths) { Class.new.extend Capistrano::DSL::Paths }
let(:linked_dirs) { %w{log public/system} }
let(:linked_files) { %w{config/database.yml log/my.log} }
let(:linked_files) { %w{config/database.yml log/my.log log/access.log} }
before do
dsl.set(:deploy_to, '/var/www')
@ -21,7 +21,10 @@ describe Capistrano::DSL::Paths do
end
it 'returns the full pathnames' do
expect(subject).to eq [Pathname.new('/var/shared/log'), Pathname.new('/var/shared/public/system')]
expect(subject).to eq [
Pathname.new('/var/shared/log'),
Pathname.new('/var/shared/public/system'),
]
end
end
@ -34,7 +37,11 @@ describe Capistrano::DSL::Paths do
end
it 'returns the full pathnames' do
expect(subject).to eq [Pathname.new('/var/shared/config/database.yml'), Pathname.new('/var/shared/log/my.log')]
expect(subject).to eq [
Pathname.new('/var/shared/config/database.yml'),
Pathname.new('/var/shared/log/my.log'),
Pathname.new('/var/shared/log/access.log'),
]
end
end
@ -46,7 +53,10 @@ describe Capistrano::DSL::Paths do
end
it 'returns the full paths names of the parent dirs' do
expect(subject).to eq [Pathname.new('/var/shared/config'), Pathname.new('/var/shared/log')]
expect(subject).to eq [
Pathname.new('/var/shared/config'),
Pathname.new('/var/shared/log'),
]
end
end
@ -58,7 +68,10 @@ describe Capistrano::DSL::Paths do
end
it 'returns the full paths names of the parent dirs' do
expect(subject).to eq [Pathname.new('/var/shared'), Pathname.new('/var/shared/public')]
expect(subject).to eq [
Pathname.new('/var/shared'),
Pathname.new('/var/shared/public'),
]
end
end