|
5 | 5 | module Puppet::Modulebuilder
|
6 | 6 | # Class to build Puppet Modules from source
|
7 | 7 | class Builder
|
8 |
| - DEFAULT_IGNORED = [ |
| 8 | + # Due to the way how PathSpec generates the regular expression, |
| 9 | + # `/*` doesn't match directories starting with a dot, |
| 10 | + # so we need `/.*` as well. |
| 11 | + IGNORED = [ |
| 12 | + '/**', |
9 | 13 | '/.*',
|
10 |
| - '/pkg/', |
11 |
| - '~*', |
12 |
| - '/coverage', |
13 |
| - '/checksums.json', |
14 |
| - '/REVISION', |
15 |
| - '/spec/fixtures/modules/', |
16 |
| - '/vendor/', |
| 14 | + '!/CHANGELOG*', |
| 15 | + '!/LICENSE', |
| 16 | + '!/README*', |
| 17 | + '!/REFERENCE.md', |
| 18 | + '!/bolt_plugin.json', |
| 19 | + '!/data/**', |
| 20 | + '!/docs/**', |
| 21 | + '!/files/**', |
| 22 | + '!/hiera.yaml', |
| 23 | + '!/locales/**', |
| 24 | + '!/manifests/**', |
| 25 | + '!/metadata.json', |
| 26 | + '!/plans/**', |
| 27 | + '!/scripts/**', |
| 28 | + '!/tasks/**', |
| 29 | + '!/templates/**', |
| 30 | + '!/types/**', |
17 | 31 | ].freeze
|
18 | 32 |
|
19 | 33 | attr_reader :destination, :logger
|
@@ -168,21 +182,6 @@ def warn_symlink(path)
|
168 | 182 | from: symlink_path.relative_path_from(module_path), to: symlink_path.realpath.relative_path_from(module_path))
|
169 | 183 | end
|
170 | 184 |
|
171 |
| - # Select the most appropriate ignore file in the module directory. |
172 |
| - # |
173 |
| - # In order of preference, we first try `.pdkignore`, then `.pmtignore` |
174 |
| - # and finally `.gitignore`. |
175 |
| - # |
176 |
| - # @return [String] The path to the file containing the patterns of file |
177 |
| - # paths to ignore. |
178 |
| - def ignore_file |
179 |
| - @ignore_file ||= [ |
180 |
| - File.join(source, '.pdkignore'), |
181 |
| - File.join(source, '.pmtignore'), |
182 |
| - File.join(source, '.gitignore'), |
183 |
| - ].find { |file| file_exists?(file) && file_readable?(file) } |
184 |
| - end |
185 |
| - |
186 | 185 | # Checks if the path contains any non-ASCII characters.
|
187 | 186 | #
|
188 | 187 | # Java will throw an error when it encounters a path containing
|
@@ -251,20 +250,10 @@ def build_package
|
251 | 250 | def ignored_files
|
252 | 251 | require 'pathspec'
|
253 | 252 |
|
254 |
| - @ignored_files ||= |
255 |
| - begin |
256 |
| - ignored = if ignore_file.nil? |
257 |
| - PathSpec.new |
258 |
| - else |
259 |
| - PathSpec.new(read_file(ignore_file, open_args: 'rb:UTF-8')) |
260 |
| - end |
261 |
| - |
262 |
| - ignored = ignored.add("/#{File.basename(destination)}/") if File.realdirpath(destination).start_with?(File.realdirpath(source)) |
| 253 | + ignored = PathSpec.new(IGNORED) |
| 254 | + ignored.add("/#{File.basename(destination)}/") if File.realdirpath(destination).start_with?(File.realdirpath(source)) |
263 | 255 |
|
264 |
| - DEFAULT_IGNORED.each { |r| ignored.add(r) } |
265 |
| - |
266 |
| - ignored |
267 |
| - end |
| 256 | + ignored |
268 | 257 | end
|
269 | 258 |
|
270 | 259 | # Create a temporary build directory where the files to be included in
|
|
0 commit comments