Skip to content

Commit

Permalink
Ignore invalid versions in the forge, ie. 0.5.0-rc1
Browse files Browse the repository at this point in the history
Instead of failing completely
  • Loading branch information
Carlos Sanchez committed Dec 14, 2012
1 parent 5e2be5b commit 6b42807
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
12 changes: 12 additions & 0 deletions features/install.feature
Expand Up @@ -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:
"""
Expand Down
9 changes: 7 additions & 2 deletions lib/librarian/puppet/source/forge.rb
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 6b42807

Please sign in to comment.