-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(PDK-804) Fixes error in build without ignore file #425
Conversation
eba85a0
to
c0d55f8
Compare
lib/pdk/module/build.rb
Outdated
@@ -196,6 +196,13 @@ def ignored_files | |||
|
|||
PathSpec.new(data) | |||
end | |||
|
|||
# Also ignore the target directory if it is in the module dir and not already ignored | |||
if Find.find(@module_dir).include?(@target_dir) && !@ignored_files.match(File.basename(@target_dir) + '/') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than calling Find.find
here (which might get expensive), could we get away with something like:
if @ignored_files.specs_matching(target_dir).empty?
@ignored_files.add("\/#{File.basename(target_dir)}\/")
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That wouldn't guard against the scenario where target-dir
wasn't a sub directory of the module_dir
. If target-dir
was /tmp/pkg/
then @ignored_files.specs_matching('/tmp/pkg/').empty?
would be true
, and /pkg/
would get added to the ignored_files a second time.
lib/pdk/module/build.rb
Outdated
|
||
# Also ignore the target directory if it is in the module dir and not already ignored | ||
if Find.find(@module_dir).include?(@target_dir) && !@ignored_files.match(File.basename(@target_dir) + '/') | ||
@ignored_files = @ignored_files.add("\/#{File.basename(@target_dir)}\/") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should use target_dir
reader method rather than referencing the instance variable directly (here and in the line above), makes it easier to mock when unit testing.
pdk will now make sure that if there is no ignore file and if the pkg target-dir is in the module_dir, then it will add the target-dir to the ignores list.
pdk will now make sure that if there is no ignore file and if the pkg
target-dir is in the module_dir, then it will add the target-dir
to the ignores list.