lib/pdk/context.rb in pdk-2.7.1 vs lib/pdk/context.rb in pdk-3.0.0
- old
+ new
@@ -18,13 +18,11 @@
# Control Repo detection
return PDK::Context::ControlRepo.new(current, context_path) if PDK.feature_flag?('controlrepo') && PDK::ControlRepo.control_repo_root?(current)
# Puppet Module detection
metadata_file = File.join(current, 'metadata.json')
- if PDK::Util::Filesystem.file?(metadata_file) || PDK::Util.in_module_root?(context_path)
- return PDK::Context::Module.new(current, context_path)
- end
+ return PDK::Context::Module.new(current, context_path) if PDK::Util::Filesystem.file?(metadata_file) || PDK::Util.in_module_root?(context_path)
previous = current
current = PDK::Util::Filesystem.expand_path('..', current)
end
PDK::Context::None.new(context_path)
@@ -80,20 +78,21 @@
depth = 1
loop do
PDK.logger.debug("Detected #{current.display_name} at #{current.root_path.nil? ? current.context_path : current.root_path}")
current = current.parent_context
break if current.nil?
+
depth += 1
# Circuit breaker in case there are circular references
break if depth > 20
end
nil
end
- #:nocov: There's nothing to test here
+ # :nocov: There's nothing to test here
def to_s
"#<#{self.class}:#{object_id}>#{context_path}"
end
- #:nocov:
+ # :nocov:
end
end
end