On Mon, 6 Jul 2020 at 19:41, Craig Russell <apache....@gmail.com> wrote: > > 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
Probably easiest to use svnmucc for this. The put command copies a local file to the repo, and if you specify revision 0 it will fail if there is already such a file. It also supports propset, and AFAIK it will work on a brand new file. > > Craig L Russell > c...@apache.org >