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 2016/09/11 18:23:39 UTC
[whimsy] 01/02: rough in ICLA/svn (no commit just yet)
This is an automated email from the ASF dual-hosted git repository.
rubys pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/whimsy.git
commit a2131e83f31d6e76142b903c2c4cbe81512bef26
Author: Sam Ruby <ru...@intertwingly.net>
AuthorDate: Sun Sep 11 14:15:32 2016 -0400
rough in ICLA/svn (no commit just yet)
---
www/secmail/Gemfile | 2 +-
www/secmail/config.ru | 1 +
www/secmail/helpers.rb | 10 --------
www/secmail/models/message.rb | 2 +-
www/secmail/server.rb | 13 ++++------
www/secmail/views/actions/icla.json.rb | 45 ++++++++++++++++++++++++++++------
6 files changed, 46 insertions(+), 27 deletions(-)
diff --git a/www/secmail/Gemfile b/www/secmail/Gemfile
index 09e6349..1246f8a 100644
--- a/www/secmail/Gemfile
+++ b/www/secmail/Gemfile
@@ -6,7 +6,7 @@ gem 'zip'
gem 'whimsy-asf', '~> 0.0.73'
gem 'sinatra'
gem 'sanitize'
-gem 'wunderbar', '~> 1.0.13'
+gem 'wunderbar', '~> 1.0.26'
gem 'ruby2js', '~> 2.0.12'
gem 'execjs'
gem 'listen', ('~> 3.0.7' if RUBY_VERSION =~ /^2\.[01]/)
diff --git a/www/secmail/config.ru b/www/secmail/config.ru
index d45fd87..0a8f5e0 100644
--- a/www/secmail/config.ru
+++ b/www/secmail/config.ru
@@ -3,6 +3,7 @@ require File.expand_path('../server.rb', __FILE__)
require 'whimsy/asf/rack'
use ASF::HTTPS_workarounds
+use ASF::Auth::MembersAndOfficers
use ASF::AutoGC
run Sinatra::Application
diff --git a/www/secmail/helpers.rb b/www/secmail/helpers.rb
index 1bb3732..e5c682b 100644
--- a/www/secmail/helpers.rb
+++ b/www/secmail/helpers.rb
@@ -1,14 +1,4 @@
helpers do
- # update and restore an svn checkout to a clean state
- def svn_reset(repos)
- path = File.realpath(repos).untaint
- out, err, rc = Open3.capture3 'svn', 'cleanup', path
- out, err, rc = Open3.capture3 'svn', 'revert', '--recursive', path
- out, err, rc = Open3.capture3 'svn', 'status', path
- FileUtils.rm_rf out.scan(/^\?\s+(.*)/).flatten.map(&:untaint)
- out, err, rc = Open3.capture3 'svn', 'update', path
- end
-
# replace inline images (cid:) with references to attachments
def fixup_images(node)
if Wunderbar::Node === node
diff --git a/www/secmail/models/message.rb b/www/secmail/models/message.rb
index afc0e4e..6f0823e 100644
--- a/www/secmail/models/message.rb
+++ b/www/secmail/models/message.rb
@@ -146,7 +146,7 @@ class Message
# write one or more attachments to directory containing an svn checkout
#
def write_svn(repos, filename, *attachments)
- attachments = attachments.flatten.compact
+ attachments = attachments.flatten.reject {|name| name.to_s.empty?}
if attachments.length == 1
ext = File.extname(attachments.first).untaint
diff --git a/www/secmail/server.rb b/www/secmail/server.rb
index b505d0b..ee78edf 100644
--- a/www/secmail/server.rb
+++ b/www/secmail/server.rb
@@ -16,16 +16,13 @@ require_relative 'models/events'
class Wunderbar::JsonBuilder
def _task(title, &block)
- if @task
- rc = _.system ['echo', 'hi']
- rc = _.system ['echo', rc.to_s]
- rc = _.system ['svn', 'foobar']
- rc = _.system ['echo', rc.to_s]
- rc = _.system ['foobar']
- @task = nil
- else
+ if not @task
@_target[:tasklist] ||= []
@_target[:tasklist] << title
+ elsif @task == title
+ block.call
+ @task = nil
+ else
end
end
end
diff --git a/www/secmail/views/actions/icla.json.rb b/www/secmail/views/actions/icla.json.rb
index 0c16d1b..f9fcaee 100644
--- a/www/secmail/views/actions/icla.json.rb
+++ b/www/secmail/views/actions/icla.json.rb
@@ -1,5 +1,8 @@
#
-# File an ICLA
+# File an ICLA:
+# - add files to documents/iclas
+# - add entry to officers/iclas.txt
+# - send email
#
message = Mailbox.find(@message)
@@ -10,8 +13,19 @@ fileext = File.extname(@selected) if @signature.empty?
# write attachment (+ signature, if present) to the documents/iclas directory
_task "svn commit documents/iclas/#@filename#{fileext}" do
- svn_reset iclas
- dest = message.write_svn(iclas, @filename, @selected, @signature)
+ Dir.mktmpdir do |dir|
+ # checkout empty directory
+ _.system! 'svn', 'checkout', '--depth', 'empty',
+ 'https://svn.apache.org/repos/private/documents/iclas', "#{dir}/iclas",
+ ['--non-interactive', '--no-auth-cache'],
+ ['--username', env.user.untaint, '--password', env.password.untaint]
+
+ # create/add file(s)
+ dest = message.write_svn("#{dir}/iclas", @filename, @selected, @signature)
+
+ # stub for now
+ _.system 'svn', 'status', "#{dir}/iclas"
+ end
end
# insert line into iclas.txt
@@ -25,10 +39,27 @@ _task "svn commit foundation/officers/iclas.txt" do
"Signed CLA;#{@filename}"
].join(':')
- # update iclas.txt
- svn_reset ASF::ICLA::OFFICERS
- iclas_txt = ASF::ICLA.sort(File.read(ASF::ICLA::SOURCE) + insert + "\n")
- File.write ASF::ICLA::SOURCE, iclas_txt
+ Dir.mktmpdir do |dir|
+ # checkout empty officers directory
+ _.system! 'svn', 'checkout', '--depth', 'empty',
+ 'https://svn.apache.org/repos/private/foundation/officers',
+ "#{dir}/officers",
+ ['--non-interactive', '--no-auth-cache'],
+ ['--username', env.user.untaint, '--password', env.password.untaint]
+
+ # retrieve iclas.txt
+ dest = "#{dir}/officers/iclas.txt"
+ _.system! 'svn', 'update', dest,
+ ['--non-interactive', '--no-auth-cache'],
+ ['--username', env.user.untaint, '--password', env.password.untaint]
+
+ # update iclas.txt
+ iclas_txt = ASF::ICLA.sort(File.read(dest) + insert + "\n")
+ File.write dest, iclas_txt
+
+ # show the changes
+ _.system 'svn', 'diff', dest
+ end
end
# send confirmation email
--
To stop receiving notification emails like this one, please contact
"commits@whimsical.apache.org" <co...@whimsical.apache.org>.