whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [whimsy] branch master updated: WHIMSY-271 Centralise committee-info.txt roster update handling
Date Mon, 03 Jun 2019 17:22:49 GMT
This is an automated email from the ASF dual-hosted git repository.

sebb 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 2366488  WHIMSY-271 Centralise committee-info.txt roster update handling
2366488 is described below

commit 2366488d4d8fc30547833edccd6de4799b884ccf
Author: Sebb <sebb@apache.org>
AuthorDate: Mon Jun 3 18:22:32 2019 +0100

    WHIMSY-271 Centralise committee-info.txt roster update handling
    
    1 of 2: Update nonpmc code; second version with cache updated
---
 lib/whimsy/asf/svn.rb                   | 62 ++++++++++++++++++++++++++++++---
 www/roster/views/actions/nonpmc.json.rb |  3 +-
 2 files changed, 59 insertions(+), 6 deletions(-)

diff --git a/lib/whimsy/asf/svn.rb b/lib/whimsy/asf/svn.rb
index 711018a..2561559 100644
--- a/lib/whimsy/asf/svn.rb
+++ b/lib/whimsy/asf/svn.rb
@@ -211,6 +211,47 @@ module ASF
       revision
     end
 
+    # Specialised code for updating CI
+    # Updates cache if SVN commit succeeds
+    # user and password are required because the default URL is private
+    def self.updateCI(msg, env, options={})
+      # Allow override for testing
+      ciURL = options[:url] || 'https://svn.apache.org/repos/private/committers/board'
+      Dir.mktmpdir do |tmpdir|
+        # use dup to make testing easier
+        user = env.user.dup.untaint
+        pass = env.password.dup.untaint
+        # checkout committers/board
+        Kernel.system 'svn', 'checkout', '--quiet',
+          '--no-auth-cache', '--non-interactive',
+          '--depth', 'files',
+          '--username', user , '--password', pass,
+          ciURL, tmpdir.untaint
+        # read in committee-info.txt
+        file = File.join(tmpdir, 'committee-info.txt')
+        info = File.read(file)
+
+        info = yield info # get the updates the contents
+
+        # write updated file to disk
+        File.write(file, info)
+
+        # commit changes
+        rc = Kernel.system 'svn', 'commitx', '--quiet',
+          '--no-auth-cache', '--non-interactive',
+          '--username', user, '--password', pass,
+          file, '--message', msg
+
+        if rc
+          # update cache
+          ASF::Committee.parse_committee_info(info)
+        else
+          # die
+          raise Exception.new('Update committee-info.txt failed')
+        end
+      end
+    end
+
     # update a file or directory in SVN, working entirely in a temporary
     # directory
     # Intended for use from GUI code
@@ -301,8 +342,21 @@ module ASF
 end
 
 if __FILE__ == $0 # local testing
-  path = ARGV.shift||'.'
-  puts ASF::SVN.list(path, *ARGV)
-  puts ASF::SVN.getInfo(path, *ARGV)
-  puts ASF::SVN.getRevision(path, *ARGV)
+  class ENV_
+    def self.user
+      ENV['USER']
+    end
+    def self.password
+      'x x'
+    end
+  end
+  $LOAD_PATH.unshift '/srv/whimsy/lib'
+#  require 'whimsy/asf'
+  ASF::SVN.updateCI("msg",ENV_,{url: 'file:///Users/sebb/REPO'}) do |content|
+    ""
+  end
+#  path = ARGV.shift||'.'
+#  puts ASF::SVN.list(path, *ARGV)
+#  puts ASF::SVN.getInfo(path, *ARGV)
+#  puts ASF::SVN.getRevision(path, *ARGV)
 end
diff --git a/www/roster/views/actions/nonpmc.json.rb b/www/roster/views/actions/nonpmc.json.rb
index b5c2de0..a4a9667 100644
--- a/www/roster/views/actions/nonpmc.json.rb
+++ b/www/roster/views/actions/nonpmc.json.rb
@@ -37,9 +37,8 @@ if env.password
 
   # update committee-info.txt
   if @targets.include? 'info'
-    cinfo = File.join(ASF::SVN['board'], 'committee-info.txt')
     message = "#{@project} #{@action == 'add' ? '+' : '-'}= #{who}".untaint
-    ASF::SVN.update cinfo, message, env, _ do |tmpdir, contents|
+    ASF::SVN.updateCI message, env do |contents|
       contents = ASF::Committee.update_roster(contents, @project, people, @action)
       contents
     end


Mime
View raw message