whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ru...@apache.org
Subject [whimsy] branch master updated: reload svn mappings when repository.yml changes
Date Mon, 12 Jun 2017 13:36:07 GMT
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 3a84942  reload svn mappings when repository.yml changes
3a84942 is described below

commit 3a849427809696a23c7477d8168e4f6f31ef95d9
Author: Sam Ruby <rubys@intertwingly.net>
AuthorDate: Mon Jun 12 09:35:32 2017 -0400

    reload svn mappings when repository.yml changes
---
 lib/whimsy/asf/svn.rb | 33 +++++++++++++++++++++++++--------
 1 file changed, 25 insertions(+), 8 deletions(-)

diff --git a/lib/whimsy/asf/svn.rb b/lib/whimsy/asf/svn.rb
index 6811a3e..134609c 100644
--- a/lib/whimsy/asf/svn.rb
+++ b/lib/whimsy/asf/svn.rb
@@ -12,18 +12,35 @@ module ASF
     @semaphore = Mutex.new
     @testdata = {}
 
+    REPOSITORY = File.expand_path('../../../../repository.yml', __FILE__).
+      untaint
+    @@repository_mtime = nil
+
     def self.repos
       @semaphore.synchronize do
         svn = Array(ASF::Config.get(:svn)).map {|dir| dir.untaint}
-        @repos ||= Hash[Dir[*svn].map { |name| 
-          next unless Dir.exist? name.untaint
-          Dir.chdir name.untaint do
-            out, err, status = Open3.capture3('svn', 'info')
-            if status.success?
-              [out[/URL: (.*)/,1].sub(/^http:/,'https:'), Dir.pwd.untaint]
+
+        # reload if repository changes
+        if File.exist?(REPOSITORY) && @@repository_mtime!=File.mtime(REPOSITORY)
+          @repos = nil
+        end
+
+        # reuse previous results if already scanned
+        unless @repos
+          @@repository_mtime = File.exist?(REPOSITORY) && File.mtime(REPOSITORY)
+
+          @repos = Hash[Dir[*svn].map { |name| 
+            next unless Dir.exist? name.untaint
+            Dir.chdir name.untaint do
+              out, err, status = Open3.capture3('svn', 'info')
+              if status.success?
+                [out[/URL: (.*)/,1].sub(/^http:/,'https:'), Dir.pwd.untaint]
+              end
             end
-          end
-        }.compact]
+          }.compact]
+        end
+
+        @repos
       end
     end
 

-- 
To stop receiving notification emails like this one, please contact
['"commits@whimsical.apache.org" <commits@whimsical.apache.org>'].

Mime
View raw message