Match a dot in paths configured for only: changes

This commit is contained in:
Grzegorz Bizon 2018-10-02 15:04:32 +02:00
parent 0f78ceca1b
commit b772e7f4c6
2 changed files with 10 additions and 2 deletions

View file

@ -11,7 +11,9 @@ module Gitlab
return true unless pipeline.branch_updated?
pipeline.modified_paths.any? do |path|
@globs.any? { |glob| File.fnmatch?(glob, path, File::FNM_PATHNAME) }
@globs.any? do |glob|
File.fnmatch?(glob, path, File::FNM_PATHNAME | File::FNM_DOTMATCH)
end
end
end
end

View file

@ -19,7 +19,7 @@ describe Gitlab::Ci::Build::Policy::Changes do
before do
allow(pipeline).to receive(:modified_paths) do
%w[some/modified/ruby/file.rb some/other_file.txt]
%w[some/modified/ruby/file.rb some/other_file.txt some/.dir/file]
end
end
@ -42,6 +42,12 @@ describe Gitlab::Ci::Build::Policy::Changes do
expect(policy).to be_satisfied_by(pipeline, seed)
end
it 'is satisfied by matching a pattern with a dot' do
policy = described_class.new(%w[some/*/file])
expect(policy).to be_satisfied_by(pipeline, seed)
end
it 'is not satisfied when pattern does not match path' do
policy = described_class.new(%w[some/*.rb])