whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sam Ruby <ru...@apache.org>
Subject [whimsy.git] [1/1] Commit d147de2: fetch authorization from git if available
Date Wed, 09 Mar 2016 16:50:27 GMT
Commit d147de21c1ad8eefd426845d0f9f280b212e4380:
    fetch authorization from git if available
    fall back to svn if not


Branch: refs/heads/master
Author: Sam Ruby <rubys@intertwingly.net>
Committer: Sam Ruby <rubys@intertwingly.net>
Pusher: rubys <rubys@apache.org>

------------------------------------------------------------
lib/whimsy/asf.rb                                            | + 
lib/whimsy/asf/auth.rb                                       | +++++++ -
lib/whimsy/asf/git.rb                                        | ++++++++++++ 
------------------------------------------------------------
57 changes: 56 additions, 1 deletions.
------------------------------------------------------------


diff --git a/lib/whimsy/asf.rb b/lib/whimsy/asf.rb
index 45aa021..9e37ab0 100644
--- a/lib/whimsy/asf.rb
+++ b/lib/whimsy/asf.rb
@@ -3,6 +3,7 @@
 require_relative 'asf/ldap'
 require_relative 'asf/mail'
 require_relative 'asf/svn'
+require_relative 'asf/git'
 require_relative 'asf/watch'
 require_relative 'asf/nominees'
 require_relative 'asf/icla'
diff --git a/lib/whimsy/asf/auth.rb b/lib/whimsy/asf/auth.rb
index 85c9063..3febb40 100644
--- a/lib/whimsy/asf/auth.rb
+++ b/lib/whimsy/asf/auth.rb
@@ -12,7 +12,13 @@ def initialize(file='asf')
     end
 
     def each
-      auth = ASF::SVN['infra/infrastructure/trunk/subversion/authorization']
+      auth = ASF::Git.find('infrastructure-puppet')
+      if auth
+        auth += '/modules/subversion_server/files/authorization'
+      else
+        auth = ASF::SVN['infra/infrastructure/trunk/subversion/authorization']
+      end
+
       File.read("#{auth}/#{@file}-authorization-template").
         scan(/^([-\w]+)=(\w.*)$/).each do |pmc, ids|
         yield pmc, ids.split(',')
diff --git a/lib/whimsy/asf/git.rb b/lib/whimsy/asf/git.rb
new file mode 100644
index 0000000..977e509
--- /dev/null
+++ b/lib/whimsy/asf/git.rb
@@ -0,0 +1,48 @@
+require 'thread'
+require 'open3'
+
+module ASF
+
+  class Git
+    @semaphore = Mutex.new
+
+    def self.repos
+      @semaphore.synchronize do
+        git = Array(ASF::Config.get(:git)).map {|dir| dir.untaint}
+        @repos ||= Hash[Dir[*git].map { |name| 
+          next unless Dir.exist? name.untaint
+          Dir.chdir name.untaint do
+            out, err, status = 
+              Open3.capture3(*%(git config --get remote.origin.url))
+            if status.success?
+              [File.basename(out.chomp, '.git'), Dir.pwd.untaint]
+            end
+          end
+        }.compact]
+      end
+    end
+
+    def self.[]=(name, path)
+      @testdata[name] = File.expand_path(path).untaint
+    end
+
+    def self.[](name)
+      self.find!(name)
+    end
+
+    def self.find(name)
+      repos[name]
+    end
+
+    def self.find!(name)
+      result = self.find(name)
+
+      if not result
+        raise Exception.new("Unable to find git clone for #{name}")
+      end
+
+      result
+    end
+  end
+
+end

Mime
View raw message