You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by ru...@apache.org on 2018/04/30 23:20:20 UTC

[whimsy] branch master updated: cache parsed contents of repository.yml

This is an automated email from the ASF dual-hosted git repository.

rubys pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new 892c7c2  cache parsed contents of repository.yml
892c7c2 is described below

commit 892c7c25f6f2a2cf4420a98580dc859b1428b6d8
Author: Sam Ruby <ru...@intertwingly.net>
AuthorDate: Mon Apr 30 19:19:57 2018 -0400

    cache parsed contents of repository.yml
---
 lib/whimsy/asf/svn.rb | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lib/whimsy/asf/svn.rb b/lib/whimsy/asf/svn.rb
index 743e814..791f647 100644
--- a/lib/whimsy/asf/svn.rb
+++ b/lib/whimsy/asf/svn.rb
@@ -24,6 +24,7 @@ module ASF
     REPOSITORY = File.expand_path('../../../../repository.yml', __FILE__).
       untaint
     @@repository_mtime = nil
+    @@repository_entries = nil
 
     # a hash of local working copies of Subversion repositories.  Keys are
     # subversion paths; values are file paths.
@@ -39,6 +40,7 @@ module ASF
         # reuse previous results if already scanned
         unless @repos
           @@repository_mtime = File.exist?(REPOSITORY) && File.mtime(REPOSITORY)
+          @@repository_entries = YAML.load_file(REPOSITORY)
 
           @repos = Hash[Dir[*svn].map { |name| 
             next unless Dir.exist? name.untaint
@@ -67,6 +69,12 @@ module ASF
       self.find!(name)
     end
 
+    # fetch a repository entry by name
+    def self.repo_entry(name)
+      self.repos # refresh @@repository_entries
+      @@repository_entries[:svn][name]
+    end
+
     # find a local directory corresponding to a path in Subversion.  Returns
     # <tt>nil</tt> if not found.
     def self.find(name)
@@ -77,7 +85,7 @@ module ASF
 
       # if name is a simple identifier (may contain '-'), try to match name in repository.yml
       if not result and name =~ /^[\w-]+$/
-        entry = YAML.load_file(REPOSITORY)[:svn][name]
+        entry = repo_entry(name)
         result = find((@base+entry['url']).to_s) if entry
       end
 

-- 
To stop receiving notification emails like this one, please contact
rubys@apache.org.