Skip to content

Commit

Permalink
Fetch the module version from the Modulefile when cloning a git repo
Browse files Browse the repository at this point in the history
  • Loading branch information
Branan Purvine-Riley committed Jul 31, 2012
1 parent 6d478ff commit 5f29751
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/librarian/puppet/source/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ def hash_from(remote, reference)
run!(command, :chdir => true).strip
end

# Naming this method 'version' causes an exception to be raised.
def module_version
return '0.0.1' unless modulefile?

metadata = ::Puppet::ModuleTool::Metadata.new
::Puppet::ModuleTool::ModulefileReader.evaluate(metadata, modulefile)

metadata.version
end

def dependencies
return {} unless modulefile?

Expand Down Expand Up @@ -45,6 +55,12 @@ module Source
class Git < Librarian::Source::Git
include Local

def fetch_version(name, extra)
cache!
found_path = found_path(name)
repository.module_version
end

def fetch_dependencies(name, version, extra)
repository.dependencies.map do |k, v|
Dependency.new(k, v, nil)
Expand Down

0 comments on commit 5f29751

Please sign in to comment.