diff --git a/README.md b/README.md index 0328b66..b0c019e 100644 --- a/README.md +++ b/README.md @@ -145,6 +145,9 @@ forges: - Directory: /var/lib/other-modules - Source: /var/code/puppetlabs-apache - Proxy: http://forge.puppetlabs.com + - GitRepository: + source: https://github.com/puppetlabs/puppetlabs-stdlib.git + include_tags: '[0-9.]+' ``` ## Running with Phusion Passenger (EXPERIMENTAL) diff --git a/lib/puppet_library/forge/git_repository.rb b/lib/puppet_library/forge/git_repository.rb index f81f957..0ab9988 100644 --- a/lib/puppet_library/forge/git_repository.rb +++ b/lib/puppet_library/forge/git_repository.rb @@ -56,9 +56,11 @@ def self.configure(&block) # * :source - The URL or path of the git repository # * :version_tag_regex - A regex that describes which tags to serve - def initialize(git, version_tag_regex) + def initialize(source, version_tag_regex) super(self) - @version_tag_regex = version_tag_regex + @version_tag_regex = Regexp.new version_tag_regex[1] + cache_dir = PuppetLibrary::Util::TempDir.new("git-repo-cache") + git = PuppetLibrary::Util::Git.new(source[1], cache_dir) @git = git @metadata_cache = PuppetLibrary::Http::Cache::InMemory.new(60) @tags_cache = PuppetLibrary::Http::Cache::InMemory.new(60) @@ -105,7 +107,7 @@ def get_metadata(author, module_name) def tags @tags_cache.get do tags = @git.tags - tags = tags.select {|tag| tag =~ @version_tag_regex } + tags = tags.select {|tag| @version_tag_regex =~ tag } tags = tags.select do |tag| @git.file_exists?("metadata.json", tag) || @git.file_exists?("Modulefile", tag) end