diff --git a/features/install.feature b/features/install.feature index f03a92c9..c016ee48 100644 --- a/features/install.feature +++ b/features/install.feature @@ -27,6 +27,18 @@ Feature: cli/install And the file "modules/apt/Modulefile" should match /version *'0\.0\.4'/ And the file "modules/stdlib/Modulefile" should match /name *'puppetlabs-stdlib'/ + Scenario: Installing a module with invalid versions in the forge + Given a file named "Puppetfile" with: + """ + forge "http://forge.puppetlabs.com" + + mod 'puppetlabs/apache', '0.4.0' + """ + When I run `librarian-puppet install` + Then the exit status should be 0 + And the file "modules/apache/Modulefile" should match /name *'puppetlabs-apache'/ + And the file "modules/apache/Modulefile" should match /version *'0\.4\.0'/ + Scenario: Installing a module with several constraints Given a file named "Puppetfile" with: """ diff --git a/lib/librarian/puppet/source/forge.rb b/lib/librarian/puppet/source/forge.rb index 14055b43..6eeb1b94 100644 --- a/lib/librarian/puppet/source/forge.rb +++ b/lib/librarian/puppet/source/forge.rb @@ -22,7 +22,9 @@ def versions raise Error, "Unable to find module '#{name}' on #{source}" end - data['releases'].map { |r| r['version'] }.sort.reverse + versions = data['releases'].map { |r| r['version'] }.sort.reverse + versions.select { |v| ! Gem::Version.correct? v }.each { |v| debug { "Ignoring invalid version '#{v}' for module #{name}" } } + versions.select { |v| Gem::Version.correct? v } end def dependencies(version) @@ -104,7 +106,6 @@ def cache_version_unpacked!(version) path.unlink raise Error, "Error executing puppet module install:\n#{command}\nError:\n#{output}" end - end def check_puppet_module_options @@ -148,6 +149,10 @@ def stream(file, &block) end end + def debug(*args, &block) + environment.logger.debug(*args, &block) + end + private def api_call(path)