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 efad7aa multiUpdate_ -- add :tmpdir support
efad7aa is described below
commit efad7aac778c2b3a4e714998c728bfc8a63c8cb0
Author: Sebb <[email protected]>
AuthorDate: Thu Jul 23 22:37:58 2020 +0100
multiUpdate_ -- add :tmpdir support
---
lib/whimsy/asf/svn.rb | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/lib/whimsy/asf/svn.rb b/lib/whimsy/asf/svn.rb
index 65c3ff7..621d01f 100644
--- a/lib/whimsy/asf/svn.rb
+++ b/lib/whimsy/asf/svn.rb
@@ -2,6 +2,7 @@ require 'uri'
require 'open3'
require 'fileutils'
require 'tmpdir'
+require 'tempfile'
module ASF
@@ -701,7 +702,6 @@ module ASF
raise ArgumentError.new "Following options not recognised:
#{bad_keys.inspect}"
end
- require 'tempfile'
temp = options[:tmpdir]
tmpdir = temp ? temp : Dir.mktmpdir.untaint
@@ -807,7 +807,6 @@ module ASF
return 1 if self.exist?(target, parentrev, env, options)
rc = nil
Dir.mktmpdir do |tmpdir|
- require 'tempfile'
source = Tempfile.new('create_source', tmpdir)
File.write(source, text)
commands = [['put', source.path, target]]
@@ -836,6 +835,10 @@ module ASF
# message - commit message
# env - for username and password
# _ - Wunderbar context
+ # options:
+ # :dryrun - don't do the update
+ # :verbose - show what will be done
+ # :tmpdir - use this temporary directory (and don't remove it)
# For example:
# ASF::SVN.multiUpdate_(path,message,env,_) do |text|
# out = '...'
@@ -846,8 +849,7 @@ module ASF
# [out, extra]
# end
def self.multiUpdate_(path, msg, env, _, options = {})
- require 'tempfile'
- tmpdir = Dir.mktmpdir.untaint
+ tmpdir = options[:tmpdir] || Dir.mktmpdir.untaint
if File.file? path
basename = File.basename(path).untaint
parentdir = File.dirname(path).untaint
@@ -905,7 +907,7 @@ module ASF
rc
end
ensure
- FileUtils.rm_rf tmpdir
+ FileUtils.rm_rf tmpdir unless options[:tmpdir]
end
end