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 9d35536 SVN.create_ now requires source text, not file
9d35536 is described below
commit 9d355367894178f6d3840cead97324ac68884507
Author: Sebb <[email protected]>
AuthorDate: Thu Jul 23 13:25:16 2020 +0100
SVN.create_ now requires source text, not file
---
lib/whimsy/asf/svn.rb | 26 ++++++++++++++++----------
www/roster/views/actions/memstat.json.rb | 30 +++++++++++++-----------------
2 files changed, 29 insertions(+), 27 deletions(-)
diff --git a/lib/whimsy/asf/svn.rb b/lib/whimsy/asf/svn.rb
index 78137ae..65c3ff7 100644
--- a/lib/whimsy/asf/svn.rb
+++ b/lib/whimsy/asf/svn.rb
@@ -787,7 +787,7 @@ module ASF
# Parameters:
# directory - parent directory as an SVN URL
# filename - name of file to create
- # source - file to upload
+ # text - text of file to create
# msg - commit message
# env - user/pass
# _ - wunderbar context
@@ -798,21 +798,27 @@ module ASF
# 0 on success
# 1 if the file exists
# IOError on unexpected error
- def self.create_(directory, filename, source, msg, env, _, options={})
+ def self.create_(directory, filename, text, msg, env, _, options={})
parentrev, err = self.getInfoItem(directory, 'revision', env.user,
env.password)
unless parentrev
throw RuntimeError.new("Failed to get revision for #{directory}:
#{err}")
end
target = File.join(directory, filename)
return 1 if self.exist?(target, parentrev, env, options)
- commands = [['put', source, target]]
- # Detect file created in parallel. This generates the error message:
- # svnmucc: E160020: File already exists: <snip> path 'xxx'
- rc = self.svnmucc_(commands, msg, env, _, parentrev, options)
- unless rc == 0
- error = _.target?['transcript'][1] rescue ''
- unless error =~ %r{^svnmucc: E160020: File already exists:}
- throw RuntimeError.new("Unexpected error creating file: #{error}")
+ rc = nil
+ Dir.mktmpdir do |tmpdir|
+ require 'tempfile'
+ source = Tempfile.new('create_source', tmpdir)
+ File.write(source, text)
+ commands = [['put', source.path, target]]
+ # Detect file created in parallel. This generates the error message:
+ # svnmucc: E160020: File already exists: <snip> path 'xxx'
+ rc = self.svnmucc_(commands, msg, env, _, parentrev,
options.merge({tmpdir: tmpdir}))
+ unless rc == 0
+ error = _.target?['transcript'][1] rescue ''
+ unless error =~ %r{^svnmucc: E160020: File already exists:}
+ throw RuntimeError.new("Unexpected error creating file: #{error}")
+ end
end
end
rc
diff --git a/www/roster/views/actions/memstat.json.rb
b/www/roster/views/actions/memstat.json.rb
index fa129d1..02dfcba 100644
--- a/www/roster/views/actions/memstat.json.rb
+++ b/www/roster/views/actions/memstat.json.rb
@@ -85,25 +85,21 @@ elsif @action == 'request_emeritus'
('Date: _______' + centered_date)).untaint
# Write the emeritus request to emeritus-requests-received
EMERITUS_REQUEST_URL =
ASF::SVN.svnpath!('emeritus-requests-received').untaint
- Dir.mktmpdir do |tmpdir|
- filename =File.join(tmpdir,'tmpfile')
- File.write(filename, signed_request)
- rc = ASF::SVN.create_(EMERITUS_REQUEST_URL, "#{USERID}.txt", filename,
"Emeritus request from #{USERNAME} (#{USERID})", env, _)
- if rc == 0
- ASF::Mail.configure
- mail = Mail.new do
- from "[email protected]"
- to "#{USERNAME}<#{USERMAIL}>"
- subject "Acknowledgement of emeritus request from #{USERNAME}"
- text_part do
- body "This acknowledges receipt of your emeritus request. You can
find the request at #{EMERITUS_REQUEST_URL}#{USERID}.txt. A copy is attached
for your records.\n\nWarm Regards,\n\nSecretary, Apache Software
Foundation\[email protected]\n\n"
- end
+ rc = ASF::SVN.create_(EMERITUS_REQUEST_URL, "#{USERID}.txt", signed_request,
"Emeritus request from #{USERNAME} (#{USERID})", env, _)
+ if rc == 0
+ ASF::Mail.configure
+ mail = Mail.new do
+ from "[email protected]"
+ to "#{USERNAME}<#{USERMAIL}>"
+ subject "Acknowledgement of emeritus request from #{USERNAME}"
+ text_part do
+ body "This acknowledges receipt of your emeritus request. You can find
the request at #{EMERITUS_REQUEST_URL}#{USERID}.txt. A copy is attached for
your records.\n\nWarm Regards,\n\nSecretary, Apache Software
Foundation\[email protected]\n\n"
end
- mail.attachments["#{USERID}.txt"] = signed_request
- mail.deliver!
- elsif rc == 1
- _warn "Request file already exists"
end
+ mail.attachments["#{USERID}.txt"] = signed_request
+ mail.deliver!
+ elsif rc == 1
+ _warn "Request file already exists"
end
elsif @action == 'request_reinstatement'
ASF::Mail.configure