SVN.create_ now requires source text, not file
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 @@
# 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 @@
# 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 @@
('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 "secretary@apache.org"
- 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\nsecretary@apache.org\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 "secretary@apache.org"
+ 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\nsecretary@apache.org\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