Skip to content
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

Merged
merged 1 commit into from
Feb 13, 2018

Conversation

bmjen
Copy link
Contributor

@bmjen bmjen commented Feb 12, 2018

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.

@coveralls
Copy link

coveralls commented Feb 12, 2018

Coverage Status

Coverage increased (+0.01%) to 91.062% when pulling 90ac514 on bmjen:pdk-804 into e12d456 on puppetlabs:master.

@bmjen bmjen force-pushed the pdk-804 branch 3 times, most recently from eba85a0 to c0d55f8 Compare February 12, 2018 23:14
@bmjen bmjen changed the title (PDK-804) Fixes error when there is no ignore file and build packages… (PDK-804) Fixes error in build without ignore file Feb 12, 2018
@bmjen bmjen requested a review from rodjek February 13, 2018 00:33
@@ -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) + '/')
Copy link
Contributor

@rodjek rodjek Feb 13, 2018

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

Copy link
Contributor Author

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.


# 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)}\/")
Copy link
Contributor

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.
@bmjen bmjen merged commit 05ae699 into puppetlabs:master Feb 13, 2018
@bmjen bmjen deleted the pdk-804 branch February 13, 2018 16:04
@chelnak chelnak added the bug label Jan 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants