Hi,
I'm looking at updating memstat.json.rb to create a new file, e.g.
foundation/emeritus-requests-received/clr.txt [1]
I've looked around and have not found anything that might shorten the work.
What I'd like is something like ASF::SVN.create!(directory, filename, contents)
that would return 0 if everything worked ok or throw a runtime exception if the
file already existed or anything else bad happened.
Is this code on the right track? Is it worth trying to make a generic function
for it?
Thanks,
Craig
[1] # Add the emeritus request to svn
require 'tempfile'
Dir.mktmpdir do |tmpdir|
parenturl = ASF::SVN.svnurl('emeritus-requests-received').untaint
ASF::SVN.svn_!('checkout', [parenturl, tmpdir], _, {depth: 'files', env:
env})
Dir.chdir(tmpdir) do
# Test for file already exists; should not get here (POST request) if it
exists
File.write(filename, signed_request)
ASF::SVN.svn_!('add', filename, _, {env: env})
ASF::SVN.svn_!('propset', ['svn:mime-type', 'text/plain; charset=utf-8',
filename], _, {env: env})
ASF::SVN.svn_!('commit', [filename], _, {env: env})
end
end
Craig L Russell
[email protected]